aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/animation.h
blob: 7cb8e12f0bc4383cc9e89f99d37db676ae3df347 (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
/* 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.
 */

/* Original name: TRIP5 / Trippancy V - the sprite animation subsystem */

#ifndef AVALANCHE_ANIMATION_H
#define AVALANCHE_ANIMATION_H

#include "avalanche/graphics.h"

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

namespace Avalanche {
class AvalancheEngine;
class Animation;

struct StatType {
	Common::String _name; // Name of character.
	Common::String _comment; // Comment.
	//
	byte _frameNum; // Number of pictures.
	byte _seq; // How many in one stride.
	byte _fgBubbleCol, _bgBubbleCol; // Foreground & background bubble colors.
	byte _acciNum; // The number according to Acci. (1=Avvy, etc.)
};

class AnimationType {
public:
	SpriteInfo _info;

	StatType _stat; // Vital statistics.
	byte _facingDir, _stepNum;
	int16 _x, _y; // Current xy coords.
	int16 _oldX[2], _oldY[2];  // Last xy coords.
	int8 _moveX, _moveY; // Amount to move sprite by, each step.
	byte _id;
	bool _quick, _visible, _homing, _doCheck;
	int16 _homingX, _homingY; // Homing x & y coords.
	byte _count; // Counts before changing step.
	byte _speedX, _speedY; // x & y speed.
	byte _animCount; // Total number of sprites.
	bool _vanishIfStill; // Do we show this sprite if it's still?
	bool _callEachStepFl; // Do we call the eachstep procedure?
	byte _eachStepProc;

	void init(byte spritenum, bool doCheck, Animation *tr); // Loads & sets up the sprite.
	void original(); // Just sets 'quick' to false.
	void andexor(); // Drops sprite onto screen.
	void turn(byte whichway); // Turns character round.
	void appear(int16 wx, int16 wy, byte wf); // Switches it 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 done();

private:
	Animation *_tr;

	bool checkCollision();
	int8 sgn(int16 val);
};

class Animation {
public:
	friend class AnimationType;

	static const byte kDirUp = 0;
	static const byte kDirRight = 1;
	static const byte kDirDown = 2;
	static const byte kDirLeft = 3;
	static const byte kDirUpRight = 4;
	static const byte kDirDownRight = 5;
	static const byte kDirDownLeft = 6;
	static const byte kDirUpLeft = 7;
	static const byte kDirStopped = 8;

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

	static const byte kProcFollowAvvyY = 1;
	static const byte kProcBackAndForth = 2;
	static const byte kProcFaceAvvy = 3;
	static const byte kProcArrow = 4;
	static const byte kProcsPludwick = 5; // Unused
	static const byte kProcGrabAvvy = 6;
	static const byte kProcGeida = 7;

	Animation(AvalancheEngine *vm);
	~Animation();

	void animLink();
	void get_back_loretta();
	void loadtrip();
	void call_special(uint16 which);
	void openDoor(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().

	AnimationType tr[kSpriteNumbMax];
	byte aa[1600];

	bool mustexclaim;
	uint16 saywhat;

private:
	AvalancheEngine *_vm;

	// CHECKME: Useless?
	// 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 hideInCupboard();
	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();
};

} // End of namespace Avalanche.

#endif // AVALANCHE_ANIMATION_H