aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/trip6.h
blob: 1f2b83d00912f8e0e5398ce18da5bbf7e3da4138 (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
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * 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.
 *
 */

/*
 * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
 * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
 */

/* TRIP5	Trippancy V - the sprite animation subsystem */


#ifndef TRIP6_H
#define TRIP6_H

#include "avalanche/graphics.h"

#include "common/scummsys.h"
#include "common/str.h"

namespace Avalanche {
class AvalancheEngine;

struct adxtype { /* Second revision of ADX type */
	Common::String name/*[13]*/; /* name of character */ // uruk: Note to self: TRAILING /0 !!! Real size: 12
	Common::String comment/*[17]*/; /* comment */ // uruk: Same here, but 16.
	byte num; /* number of pictures */
	byte seq; /* how many in one stride */
	byte fgc, bgc; /* foreground & background bubble colors */
	byte accinum; /* the number according to Acci (1=Avvy, etc.) */
};

struct trip_saver_type {
	byte whichsprite;
	byte face;
	byte step;
	int16 x;
	int16 y;
	int8 ix;
	int8 iy;
	bool visible;
	bool homing;
	bool check_me;
	byte count;
	byte xw, xs, ys;
	byte totalnum;
	int16 hx;
	int16 hy;
	bool call_eachstep;
	byte eachstep;
	bool vanishifstill;
};


class Trip;

class triptype {
public:
	SpriteInfo _info;

	adxtype a; /* vital statistics */
	byte face, step;
	int16 x, y; /* current xy coords */
	int16 ox[2], oy[2];  /* last xy coords */
	int8 ix, iy; /* amount to move sprite by, each step */
	byte whichsprite;
	bool quick, visible, homing, check_me;
	int16 hx, hy; /* homing x & y coords */
	byte count; /* counts before changing step */
	byte xs, ys; /* x & y speed */
	byte totalnum; /* total number of sprites */
	bool vanishifstill; /* Do we show this sprite if it's still? */

	bool call_eachstep; /* Do we call the eachstep procedure? */
	byte eachstep;

	void init(byte spritenum, bool do_check, Trip *tr);
	/* loads & sets up the sprite */
	void original();    /* just sets Quick to false */
	void andexor();    /* drops sprite onto screen */
	void turn(byte whichway);      /* turns him round */
	void appear(int16 wx, int16 wy, byte wf); /* switches him on */
	void bounce();    /* bounces off walls. */
	void walk();    /* prepares for andexor, etc. */
	void walkto(byte pednum);      /* home in on a point */
	void stophoming();    /* self-explanatory */
	void homestep();    /* calculates ix & iy for one homing step */
	void speed(int8 xx, int8 yy); /* sets ix & iy, non-homing, etc */
	void stopwalk();    /* Stops the sprite from moving */
	void chatter();    /* Sets up talk vars */
	void set_up_saver(trip_saver_type &v);
	void unload_saver(trip_saver_type v);

	void savedata(Common::File &f); /* Self-explanatory, */
	void loaddata(Common::File &f);  /* really. */

	void save_data_to_mem(uint16 &where);
	void load_data_from_mem(uint16 &where);
	triptype *done();

private:
	Trip *_tr;

	bool collision_check();

	int8 sgn(int16 val);
};



const int16 maxgetset = 35;

class getsettype {
public:
	bytefield gs[maxgetset];
	byte numleft;

	getsettype *init();
	void remember(bytefield r);
	void recall(bytefield &r);
};






class Trip {
public:
	friend class triptype;
	friend class getsettype;



	static const int16 up = 0;
	static const int16 right = 1;
	static const int16 down = 2;
	static const int16 left = 3;
	static const int16 ur = 4;
	static const int16 dr = 5;
	static const int16 dl = 6;
	static const int16 ul = 7;
	static const int16 stopped = 8;

	static const int16 numtr = 5; /* current max no. of sprites */



	static const int16 procfollow_avvy_y = 1;

	static const int16 procback_and_forth = 2;

	static const int16 procface_avvy = 3;

	static const int16 procarrow_procs = 4;

	static const int16 procspludwick_procs = 5;

	static const int16 procgrab_avvy = 6;

	static const int16 procgeida_procs = 7;



	Trip(AvalancheEngine *vm);

	void trippancy_link();

	void get_back_loretta();

	void loadtrip();

	void call_special(uint16 which);

	void open_the_door(byte whither, byte ped, byte magicnum); /* Handles slidey-open doors. */

	void catamove(byte ped);

	void stopwalking();

	void tripkey(char dir);

	void rwsp(byte t, byte dir);

	void apped(byte trn, byte np);

	void getback();

	void fliproom(byte room, byte ped);

	bool infield(byte which); // Returns true if you're within field "which".

	bool neardoor(); // Returns True if you're near a door.

	void readstick();

	void newspeed();

	void new_game_for_trippancy();

	void take_a_step(byte &tripnum);



	void handleMoveKey(const Common::Event &event); // To replace tripkey().


	triptype tr[numtr];
	getsettype getset[2];
	byte aa[1600];

	bool mustexclaim;
	uint16 saywhat;

private:
	AvalancheEngine *_vm;

	bytefield r;

	int16 beforex, beforey;

	byte checkfeet(int16 x1, int16 x2, int16 oy, int16 y, byte yl);

	byte geida_ped(byte which);

	void dawndelay();

	void hide_in_the_cupboard();

	bool overlaps_with_mouse();

	void follow_avvy_y(byte tripnum);

	void back_and_forth(byte tripnum);

	void face_avvy(byte tripnum);

	void arrow_procs(byte tripnum);

	void grab_avvy(byte tripnum);

	void spin(byte whichway, byte &tripnum);

	void geida_procs(byte tripnum);

	void call_andexors();

	void getsetclear();

	void tidy_up(int16 a, int16 b, int16 c, int16 d);

	void tidy_after_mouse();
};

} // End of namespace Avalanche.

#endif // TRIP6_H