1 /*  Sarien - A Sierra AGI resource interpreter engine
2  *  Copyright (C) 1999-2001 Stuart George and Claudio Matsuoka
3  *
4  *  $Id: view.h,v 1.11 2001/08/05 16:02:48 cmatsuoka Exp $
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; see docs/COPYING for further details.
9  */
10 
11 #ifndef __AGI_VIEW_H
12 #define __AGI_VIEW_H
13 
14 #ifdef __cplusplus
15 extern "C"{
16 #endif
17 
18 struct view_cel {
19 	UINT8	height;
20 	UINT8	width;
21 	UINT8	transparency;
22 	UINT8	mirror_loop;
23 	UINT8	mirror;
24 	UINT8	*data;
25 };
26 
27 struct view_loop {
28 	int num_cels;
29 	struct view_cel *cel;
30 };
31 
32 /**
33  * AGI view resource structure.
34  */
35 struct agi_view {
36 	int num_loops;
37 	struct view_loop *loop;
38 	char *descr;
39 	UINT8 *rdata;
40 };
41 
42 /**
43  * AGI view table entry
44  */
45 struct vt_entry {
46 	UINT8		step_time;
47 	UINT8		step_time_count;
48 	UINT8		entry;
49 	SINT16		x_pos;
50 	SINT16		y_pos;
51 	UINT8		current_view;
52 	struct agi_view	*view_data;
53 	UINT8		current_loop;
54 	UINT8		num_loops;
55 	struct view_loop *loop_data;
56 	UINT8		current_cel;
57 	UINT8		num_cels;
58 	struct view_cel	*cel_data;
59 	struct view_cel	*cel_data_2;
60 	SINT16		x_pos2;
61 	SINT16		y_pos2;
62 	void		*s;
63 	SINT16		x_size;
64 	SINT16		y_size;
65 	UINT8		step_size;
66 	UINT8		cycle_time;
67 	UINT8		cycle_time_count;
68 	UINT8		direction;
69 
70 #define MOTION_NORMAL		0
71 #define MOTION_WANDER		1
72 #define	MOTION_FOLLOW_EGO	2
73 #define	MOTION_MOVE_OBJ		3
74 	UINT8		motion;
75 
76 #define	CYCLE_NORMAL		0
77 #define CYCLE_END_OF_LOOP	1
78 #define	CYCLE_REV_LOOP 		2
79 #define	CYCLE_REVERSE		3
80 	UINT8		cycle;
81 
82 	UINT8		priority;
83 
84 #define DRAWN		0x0001
85 #define IGNORE_BLOCKS	0x0002
86 #define FIXED_PRIORITY	0x0004
87 #define IGNORE_HORIZON	0x0008
88 #define UPDATE		0x0010
89 #define CYCLING		0x0020
90 #define ANIMATED	0x0040
91 #define MOTION		0x0080
92 #define ON_WATER	0x0100
93 #define IGNORE_OBJECTS	0x0200
94 #define UPDATE_POS	0x0400
95 #define ON_LAND		0x0800
96 #define DONTUPDATE	0x1000
97 #define FIX_LOOP	0x2000
98 #define DIDNT_MOVE	0x4000
99 #define	ADJ_EGO_XY	0x8000
100 	UINT16		flags;
101 
102 	UINT8		parm1;
103 	UINT8		parm2;
104 	UINT8		parm3;
105 	UINT8		parm4;
106 }; /* struct vt_entry */
107 
108 #define for_each_vt_entry(x) \
109 	for (x = game.view_table; (x) < &game.view_table[MAX_VIEWTABLE]; (x)++)
110 #define if_is_ego_view(x) \
111 	if ((x) == game.view_table)
112 
113 /* Motion */
114 void    check_all_motions (void);
115 void    move_obj	(struct vt_entry *);
116 void	in_destination	(struct vt_entry *);
117 void	fix_position	(int);
118 void	update_position	(void);
119 
120 /* View table management */
121 void	set_cel		(struct vt_entry *, int);
122 void	set_loop	(struct vt_entry *, int);
123 void	set_view	(struct vt_entry *, int);
124 void	start_update	(struct vt_entry *);
125 void	stop_update	(struct vt_entry *);
126 void	update_viewtable(void);
127 
128 void	unload_view	(int);
129 int	decode_view	(int);
130 void	add_to_pic	(int, int, int, int, int, int, int);
131 void	draw_obj	(int);
132 
133 #ifdef __cplusplus
134 };
135 #endif
136 
137 #endif /* __AGI_VIEW_H */
138