1 #ifndef __COLLECTION_DEFINITION_H
2 #define __COLLECTION_DEFINITION_H
3 
4 /*
5 COLLECTION_DEFINITION.H
6 
7 	Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
8 	and the "Aleph One" developers.
9 
10 	This program is free software; you can redistribute it and/or modify
11 	it under the terms of the GNU General Public License as published by
12 	the Free Software Foundation; either version 3 of the License, or
13 	(at your option) any later version.
14 
15 	This program is distributed in the hope that it will be useful,
16 	but WITHOUT ANY WARRANTY; without even the implied warranty of
17 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 	GNU General Public License for more details.
19 
20 	This license is contained in the file "COPYING",
21 	which is included with this source code; it is available online at
22 	http://www.gnu.org/licenses/gpl.html
23 
24 Friday, June 17, 1994 11:48:27 AM
25 
26 Friday, June 17, 1994 11:27:13 PM
27 	added .minimum_light_intensity field to low-level shape.
28 Tuesday, June 21, 1994 2:59:16 PM
29 	added collection version number, added unused bytes to all structures.
30 Wednesday, June 22, 1994 3:53:22 PM
31 	scaling modifications.
32 Wednesday, June 22, 1994 10:07:38 PM
33 	added _scenery_collection type, .size field to collection_definition structure, changed
34 	�shape_indexes� to �low_level_shape_indexes� in high_level_shape_definition structure
35 Saturday, July 9, 1994 3:36:05 PM
36 	added NUMBER_OF_PRIVATE_COLORS constant.
37 */
38 
39 #include "cstypes.h"
40 #include <vector>
41 
42 /* ---------- collection definition structure */
43 
44 /* 2 added pixels_to_world to collection_definition structure */
45 /* 3 added size to collection_definition structure */
46 #define COLLECTION_VERSION 3
47 
48 /* at the beginning of the clut, used by the extractor for various opaque reasons */
49 #define NUMBER_OF_PRIVATE_COLORS 3
50 
51 enum /* collection types */
52 {
53 	_unused_collection= 0, /* raw */
54 	_wall_collection, /* raw */
55 	_object_collection, /* rle */
56 	_interface_collection, /* raw */
57 	_scenery_collection /* rle */
58 };
59 
60 struct high_level_shape_definition;
61 struct low_level_shape_definition;
62 struct bitmap_definition;
63 struct rgb_color_value;
64 
65 struct collection_definition
66 {
67 	int16 version;
68 
69 	int16 type; /* used for get_shape_descriptors() */
70 	uint16 flags; /* [unused.16] */
71 
72 	int16 color_count, clut_count;
73 	int32 color_table_offset; /* an array of clut_count arrays of color_count ColorSpec structures */
74 
75 	int16 high_level_shape_count;
76 	int32 high_level_shape_offset_table_offset;
77 
78 	int16 low_level_shape_count;
79 	int32 low_level_shape_offset_table_offset;
80 
81 	int16 bitmap_count;
82 	int32 bitmap_offset_table_offset;
83 
84 	int16 pixels_to_world; /* used to shift pixel values into world coordinates */
85 
86 	int32 size; /* used to assert offsets */
87 
88 	int16 unused[253];
89 
90 	std::vector<rgb_color_value> color_tables;
91 	std::vector<std::vector<uint8> > high_level_shapes;
92 	std::vector<low_level_shape_definition> low_level_shapes;
93 	std::vector<std::vector<uint8> > bitmaps;
94 };
95 const int SIZEOF_collection_definition = 544;
96 
97 /* ---------- high level shape definition */
98 
99 #define HIGH_LEVEL_SHAPE_NAME_LENGTH 32
100 
101 struct high_level_shape_definition // Starting with number_of_views, this is a shape_animation_data structure
102 {
103 	int16 type; /* ==0 */
104 	uint16 flags; /* [unused.16] */
105 
106 	char name[HIGH_LEVEL_SHAPE_NAME_LENGTH+2];
107 
108 	int16 number_of_views;
109 
110 	int16 frames_per_view, ticks_per_frame;
111 	int16 key_frame;
112 
113 	int16 transfer_mode;
114 	int16 transfer_mode_period; /* in ticks */
115 
116 	int16 first_frame_sound, key_frame_sound, last_frame_sound;
117 
118 	int16 pixels_to_world;
119 
120 	int16 loop_frame;
121 
122 	int16 unused[14];
123 
124 	/* see the interface.h/shape_animation_data for a decription of how many
125 	   low-level indices follow (it's not simply number_of_view * frames_per_view) */
126 	int16 low_level_shape_indexes[1];
127 };
128 const int SIZEOF_high_level_shape_definition = 90;
129 
130 /* --------- low-level shape definition */
131 
132 #define _X_MIRRORED_BIT 0x8000
133 #define _Y_MIRRORED_BIT 0x4000
134 #define _KEYPOINT_OBSCURED_BIT 0x2000
135 
136 struct low_level_shape_definition
137 {
138 	uint16 flags; /* [x-mirror.1] [y-mirror.1] [keypoint_obscured.1] [unused.13] */
139 
140 	_fixed minimum_light_intensity; /* in [0,FIXED_ONE] */
141 
142 	int16 bitmap_index;
143 
144 	/* (x,y) in pixel coordinates of origin */
145 	int16 origin_x, origin_y;
146 
147 	/* (x,y) in pixel coordinates of key point */
148 	int16 key_x, key_y;
149 
150 	int16 world_left, world_right, world_top, world_bottom;
151 	int16 world_x0, world_y0;
152 
153 	int16 unused[4];
154 };
155 const int SIZEOF_low_level_shape_definition = 36;
156 
157 /* ---------- colors */
158 
159 enum
160 {
161 	SELF_LUMINESCENT_COLOR_FLAG= 0x80
162 };
163 
164 struct rgb_color_value
165 {
166 	uint8 flags;
167 	uint8 value;
168 
169 	uint16 red, green, blue;
170 };
171 const int SIZEOF_rgb_color_value = 8;
172 
173 #endif
174