aboutsummaryrefslogtreecommitdiff
path: root/scumm/insane/insane.h
blob: c451595c71a4a139c6a55667edbc3e952132ae3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2002-2005 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $Header$
 *
 */

#if !defined(INSANE_H) && !defined(DISABLE_SCUMM_7_8)
#define INSANE_H

#include "base/engine.h"
#include "scumm/intern.h"
#include "scumm/nut_renderer.h"

#include "scumm/smush/smush_player.h"
#include "scumm/smush/chunk.h"

namespace Scumm {

#define INV_CHAIN    0
#define INV_CHAINSAW 1
#define INV_MACE     2
#define INV_2X4      3
#define INV_WRENCH   4
#define INV_BOOT     5
#define INV_HAND     6
#define INV_DUST     7

#define EN_ROTT1     0 // rottwheeler
#define EN_ROTT2     1 // rottwheeler
#define EN_ROTT3     2 // rottwheeler
#define EN_VULTF1    3 // vulture (redhead female1)
#define EN_VULTM1    4 // vulture (male with glasses)
#define EN_VULTF2    5 // vulture (redhead female2)
#define EN_VULTM2    6 // vulture (initialized as rottwheeler) (male)
#define EN_CAVEFISH  7 // Cavefish Maximum Fish
#define EN_TORQUE    8 // Father Torque
#define EN_BEN       9 // used only with handler

class Insane {
 public:
	Insane(ScummEngine_v6 *scumm);
	~Insane();

	void setSmushParams(int speed);
	void runScene(int arraynum);

	void procPreRendering(void);
	void procPostRendering(byte *renderBitmap, int32 codecparam, int32 setupsan12,
						   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void procIACT(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				  int32 setupsan13, Chunk &b, int32 size, int32 flags);
	void procSKIP(Chunk &b);
	void escapeKeyHandler(void);

 private:

	ScummEngine_v6 *_vm;
	SmushPlayer *_player;

	int32 _speed;
	bool _insaneIsRunning;

	int32 _numberArray;
   	int32 _emulTimerId;
	int32 _emulateInterrupt;
	byte _errbuf[0x7d0];
	int32 _flag1d;
	int32 _mainTimerId;
	int32 _objArray1Idx;
	int32 _objArray1Idx2;
	int32 _objArray1[101];
	int32 _objArray2Idx;
	int32 _objArray2Idx2;
	int32 _objArray2[101];
	byte _currSceneId;
	int32 _timer1Flag;
	int32 _timer3Id;
	int32 _timer4Id;
	int32 _timer6Id;
	int32 _timer7Id;
	int32 _timerSpriteId;
	byte _temp2SceneId;
	byte _tempSceneId;
	int32 _currEnemy;
	int32 _currScenePropIdx;
	int32 _currScenePropSubIdx;
	const char *_currTrsMsg;
	int16 _sceneData2Loaded;
	int16 _sceneData1Loaded;
	int16 _keyboardDisable;
	bool _needSceneSwitch;
	int32 _idx2Exceeded;
	int32 _lastKey;
	bool _beenCheated;
	bool _tiresRustle;
	int _keybOldDx;
	int _keybOldDy;
	int _velocityX;
	int _velocityY;
	int _keybX;
	int _keybY;
	int32 _firstBattle;
	bool _weaponBenJustSwitched;
	bool _kickBenProgress;
	int32 _battleScene;
	bool _kickEnemyProgress;
	bool _weaponEnemyJustSwitched;
	int32 _enHdlVar[9][9];
	int32 _smlayer_room;
	int32 _smlayer_room2;
	byte *_smush_roadrashRip; // FIXME: combine them in array
	byte *_smush_roadrsh2Rip;
	byte *_smush_roadrsh3Rip;
	byte *_smush_goglpaltRip;
	byte *_smush_tovista1Flu;
	byte *_smush_tovista2Flu;
	byte *_smush_toranchFlu;
	byte *_smush_minedrivFlu;
	byte *_smush_minefiteFlu;
	NutRenderer *_smush_bencutNut;
	NutRenderer *_smush_bensgoggNut;
	NutRenderer *_smush_iconsNut;
	NutRenderer *_smush_icons2Nut;
	bool _smush_isSanFileSetup;
	bool _isBenCut;
	int _smush_smushState;
	int _continueFrame;
	int _continueFrame1;
	int _counter1;
	int _iactSceneId;
	int _iactSceneId2;
	int _smush_setupsan17;
	int32 _smush_setupsan1;
	int16 _smush_setupsan2;
	int32 _smush_setupsan4;
	int16 _smush_frameStep;
	int16 _smush_curFrame;
	int16 _smush_frameNum1;
	int16 _smush_frameNum2;
	byte _smush_earlyFluContents[0x31a];
	int16 _enemyState[10][10];
	byte _iactBits[0x80];
	int16 _mainRoadPos;
	int16 _posBrokenCar;
	int16 _posBrokenTruck;
	int16 _posFatherTorque;
	int16 _posCave;
	int16 _posVista;
	bool _roadBranch;
	bool _roadStop;
	bool _carIsBroken;
	bool _benHasGoggles;
	bool _mineCaveIsNear;
	bool _objectDetected;
	bool _roadBumps;
	int32 _approachAnim;
	int32 _val54d;
	int32 _val57d;
	bool _val115_;
	int32 _val211d;
	int32 _val213d;
	int32 _metEnemiesListTail;
	int32 _metEnemiesList[12];

	struct enemy {
		int32 handler;
		int32 initializer;
		int16 occurences;
		int32 maxdamage;
		int32 isEmpty;
		int32 weapon;
		int32 sound;
		char  filename[20];
		int32 costume4;
		int32 costume6;
		int32 costume5;
		int16 costumevar;
		int32 maxframe;
		int32 apprAnim;
	};

	struct enemy _enemy[9];

	struct fluConf {
		int sceneId;
		byte **fluPtr;
		const char *filenamePtr;
		int startFrame;
		int numFrames;
	};

	struct fluConf _fluConf[21];

	struct sceneProp {
		int32 actor; // main actor number, -1 if not applicable
		int32 sound;
		int32 trsId;
		byte r;
		byte g;
		byte b;
		int32 counter;
		int32 maxCounter;
		int32 index;
	};

	struct sceneProp _sceneProp[139];

	struct act {
		int32 actor;
		byte  state;
		int32 room;
		int32 animTilt;
		int32 tilt;
		int32 frame;
	};

	struct actor {
		int32 damage;
		int32 maxdamage;
		int32 field_8;
		int32 frame;
		int32 tilt;
		int32 cursorX;
		int32 speed;
		int32 x;
		int32 y;
		int32 y1;
		int32 x1;
		int16 weaponClass;
		int16 animWeaponClass;
		int16 newFacingFlag;
		int16 curFacingFlag;
		bool lost;
		bool kicking;
		bool field_44;
		bool field_48; // unused
		bool defunct;
		int32 scenePropSubIdx;
		int32 field_54;
		int32 runningSound;
		int32 weapon;
		bool inventory[8];
		int32 probability;
		int32 enemyHandler;
		struct act act[4];
	};

	struct actor _actor[2];

	void initvars(void);
	void readFileToMem(const char *name, byte **buf);
	void startVideo(const char *filename, int num, int argC, int frameRate,
					 int doMainLoop, byte *fluPtr = 0, int32 startFrame = 0);
	void smush_warpMouse(int x, int y, int buttons);
	void putActors(void);
	void readState(void);
	int initScene(int sceneId);
	void stopSceneSounds(int sceneId);
	void shutCurrentScene(void);
	int loadSceneData(int scene, int flag, int phase);
	void setSceneCostumes(int sceneId);
	void setupValues(void);
	void setEnemyCostumes (void);
	void smlayer_stopSound (int idx);
	int smlayer_loadSound(int id, int flag, int phase);
	int smlayer_loadCostume(int id, int phase);
	void smlayer_setActorCostume(int actornum, int act, int costume);
	void smlayer_putActor(int actornum, int act, int x, int y, byte room);
	void smlayer_setActorLayer(int actornum, int act, int layer);
	void smlayer_setFluPalette(byte *pal, int shut_flag);

	int32 readArray(int item);
	void writeArray(int item, int value);

	bool idx1Compare(void);
	bool idx2Compare(void);
	int32 idx1Tweak(void);
	int32 idx2Tweak(void);
	void smush_setToFinish(void);
	void postCase11(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase0(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase16(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase1(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase2(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase20(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase3(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase5(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase8(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase9(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				   int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase10(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase12(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase23(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCase14(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCaseAll(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					 int32 setupsan13, int32 curFrame, int32 maxFrame);
	void postCaseMore(byte *renderBitmap, int32 codecparam, int32 setupsan12,
					  int32 setupsan13, int32 curFrame, int32 maxFrame);
	void switchSceneIfNeeded(void);
	int smush_changeState(int state);
	void init_actStruct(int actornum, int actnum, int32 actorval, byte state,
						  int32 room, int32 animtilt, int32 tilt, int32 frame);
	void init_enemyStruct(int n, int32 handler, int32 initializer,
							   int16 occurences, int32 maxdamage, int32 isEmpty,
							   int32 field_14, int32 sound, const char *filename,
							   int32 costume4, int32 costume6, int32 costume5,
							   int16 field_2C, int32 field_30, int32 field_34);
	int32 enemyHandler(int n, int32, int32, int32);
	int32 enemyInitializer(int n, int32, int32, int32);
	int32 enemy0handler(int32, int32, int32);
	int32 enemy0initializer(int32, int32, int32);
	int32 enemy1handler(int32, int32, int32);
	int32 enemy1initializer(int32, int32, int32);
	int32 enemy2handler(int32, int32, int32);
	int32 enemy2initializer(int32, int32, int32);
	int32 enemy3handler(int32, int32, int32);
	int32 enemy3initializer(int32, int32, int32);
	int32 enemy4handler(int32, int32, int32);
	int32 enemy4initializer(int32, int32, int32);
	int32 enemy5handler(int32, int32, int32);
	int32 enemy5initializer(int32, int32, int32);
	int32 enemy6handler(int32, int32, int32);
	int32 enemy6initializer(int32, int32, int32);
	int32 enemy7handler(int32, int32, int32);
	int32 enemy7initializer(int32, int32, int32);
	int32 enemy8handler(int32, int32, int32);
	int32 enemy8initializer(int32, int32, int32);
	int32 enemyBenHandler(int32, int32, int32);
	bool smlayer_isSoundRunning(int32 sound);
	bool smlayer_startSfx(int32 sound);
	bool smlayer_startVoice(int32 sound);
	void smlayer_soundSetPan(int32 sound, int32 pan);
	void smlayer_soundSetPriority(int32 sound, int32 priority);
	void smlayer_drawSomething(byte *renderBitmap, int32 codecparam,
			   int32 arg_8, int32 arg_C, int32 arg_10, NutRenderer *nutfileptr,
			   int32 arg_18, int32 arg_1C, int32 arg_20);
	void smlayer_overrideDrawActorAt(byte *, byte, byte);
	void queueSceneSwitch(int32 sceneId, byte *fluPtr, const char *filename,
						  int32 arg_C, int32 arg_10, int32 startFrame, int32 numFrames);
	void turnBen(bool battle);
	void smush_rewindCurrentSan(int arg_0, int arg_4, int arg_8);
	void smlayer_showStatusMsg(int32 arg_0, byte *renderBitmap, int32 codecparam,
							   int32 x, int32 y, int32 arg_14, int32 arg_18,
							   int32 arg_1C, const char *formatString, const char *str);
	void init_fluConfStruct(int n, int sceneId, byte **fluPtr,
							const char *filenamePtr, int startFrame, int numFrames);
	int32 processBenOnRoad(bool flag);
	void mineChooseRoad(int32 arg_0);
	void actor02Reaction(int32 buttons);
	void actor00Reaction(int32 buttons);
	void actor01Reaction(int32 buttons);
	void actor03Reaction(int32 buttons);
	void turnEnemy(bool battle);
	int32 actionBen(void);
	void chooseBenWeaponAnim(int buttons);
	void setBenAnimation(int32 actornum, int anim);
	int calcTilt(int speed);
	bool smush_eitherNotStartNewFrame(void);
	void smlayer_setActorFacing(int actornum, int actnum, int frame, int direction);
	int32 weaponMaxRange(int32 actornum);
	int32 weaponMinRange(int32 actornum);
	void switchBenWeapon(void);
	void prepareScenePropScene(int32 scenePropNum, bool arg_4, bool arg_8);
	int32 calcBenDamage(bool arg_0, bool arg_4);
	int32 weaponDamage(int32 actornum);
	void proc47(int32 actornum, int32 val);
	bool weaponBenIsEffective(void);
	bool actor1StateFlags(int state);
	bool actor0StateFlags1(int state);
	bool actor0StateFlags2(int state);
	bool loadScenePropSounds(int32 scenePropNum);
	void init_scenePropStruct(int32 n, int32 n1, int32 actornum, int32 sound, int32 trsId,
							  byte r, byte g, byte b, int32 counter, int32 maxCounter,
							  int32 index);
	int32 setBenState(void);
	bool smlayer_actorNeedRedraw(int actornum, int actnum);
	void reinitActors(void);
	const char *handleTrsTag(int32 trsId);
	void ouchSoundBen(void);
	int32 smush_setupSanWithFlu(const char *filename, int32 setupsan2, int32 step1,
							   int32 step2, int32 setupsan1, byte *fluPtr, int32 numFrames);
	void smush_setupSanFromStart(const char *filename, int32 setupsan2, int32 step1,
								 int32 step2, int32 setupsan1);
	void smush_setFrameSteps(int32 step1, int32 step2);
	void smush_setupSanFile(const char *filename, int32 offset, int32 contFrame);
	int32 getLastKey(bool arg_0);
	void drawSpeedyActor(int32 arg_0);
	void actor11Reaction(int32 buttons);
	void actor12Reaction(int32 buttons);
	void actor13Reaction(int32 buttons);
	void actor10Reaction(int32 buttons);
	int32 actionEnemy(void);
	int32 processKeyboard(void);
	int32 processMouse(void);
	void setEnemyAnimation(int32 actornum, int anim);
	void chooseEnemyWeaponAnim(int32 buttons);
	void switchEnemyWeapon(void);
	void setEnemyState(void);
	int32 calcEnemyDamage(bool arg_0, bool arg_4);
	void ouchSoundEnemy(void);
	bool weaponEnemyIsEffective(void);
	void iactScene1(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				  int32 setupsan13, Chunk &b, int32 size, int32 flags);
	void iactScene3(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				  int32 setupsan13, Chunk &b, int32 size, int32 flags);
	void iactScene4(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				  int32 setupsan13, Chunk &b, int32 size, int32 flags);
	void iactScene6(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				  int32 setupsan13, Chunk &b, int32 size, int32 flags);
	void iactScene17(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				  int32 setupsan13, Chunk &b, int32 size, int32 flags);
	void iactScene21(byte *renderBitmap, int32 codecparam, int32 setupsan12,
				  int32 setupsan13, Chunk &b, int32 size, int32 flags);
	bool isBitSet(int n);
	void setBit(int n);
	void clearBit(int n);
	void chooseEnemy(void);
	void removeEmptyEnemies(void);
	void removeEnemyFromMetList(int32);
};
} // End of namespace Insane

#endif