aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/include/gfx_tools.h
blob: 813117d63318396ba5cf84a68192b64ae3da452d (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
/* 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.
 *
 * $URL$
 * $Id$
 *
 */

/* FreeSCI 0.3.1+ graphics subsystem helper functions */


#ifndef _GFX_TOOLS_H_
#define _GFX_TOOLS_H_

#include "sci/include/gfx_system.h"
#include "sci/include/gfx_driver.h"

typedef enum {
	GFX_XLATE_FILTER_NONE,
	GFX_XLATE_FILTER_LINEAR,
	GFX_XLATE_FILTER_TRILINEAR
} gfx_xlate_filter_t;

typedef enum {
	GFXR_ANTIALIASING_NONE,
	GFXR_ANTIALIASING_SIMPLE
} gfxr_antialiasing_t;


extern int gfx_crossblit_alpha_threshold; /* Crossblitting functions use this value as threshold
		 			  ** for distinguishing between transparent and opaque
					  ** wrt alpha values */

gfx_mode_t *
gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask,
             unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift,
             int blue_shift, int alpha_shift, int palette, int flags);
/* Allocates a new gfx_mode_t structure with the specified parameters
** Parameters: (int x int) xfact x yfact: Horizontal and vertical scaling factors
**             (int) bytespp: Bytes per pixel
**             (unsigned int) red_mask: Red bit mask
**             (unsigned int) green_mask: Green bit mask
**             (unsigned int) blue_mask: Blue bit mask
**             (unsigned int) Alpha_mask: Alpha bit mask, or 0 if the alpha channel is not supported
**             (int) red_shift: Red shift value
**             (int) green_shift: Green shift value
**             (int) blue_shift: Blue shift value
**             (int) alpha_shift: Alpha shift value
**             (int) palette: Number of palette colors, 0 if we're not in palette mode
**             (int) flags: GFX_MODE_FLAG_* values ORred together, or just 0
** Returns   : (gfx_mode_t *) A newly allocated gfx_mode_t structure
*/


void
gfx_clip_box_basic(rect_t *box, int maxx, int maxy);
/* Clips a rect_t
** Parameters: (rect_t *) box: Pointer to the box to clip
**             (int x int) maxx, maxy: Maximum allowed width and height
** Returns   : (void)
*/


void
gfx_free_mode(gfx_mode_t *mode);
/* Frees all memory allocated by a mode structure
** Parameters: (gfx_mode_t *) mode: The mode to free
** Returns   : (void)
*/


gfx_pixmap_t *
gfx_new_pixmap(int xl, int yl, int resid, int loop, int cel);
/* Creates a new pixmap structure
** Parameters: (int x int) xl x yl: The dimensions (in SCI coordinates) of the pixmap
**             (int) resid: The pixmap's resource ID, or GFX_RESID_NONE
**             (int) loop: For views: The pixmap's loop number
**             (int) cel: For cels: The pixmap's cel number
** Returns   : (gfx_pixmap_t *) The newly allocated pixmap
** The following fiels are initialized:
** ID, loop, cel, index_xl, index_yl, xl, yl, data <- NULL,
** alpha_map <- NULL, internal.handle <- 0, internal.info <- NULL, colors <- NULL,
** index_scaled <- 0
*/

gfx_pixmap_t *
gfx_clone_pixmap(gfx_pixmap_t *pixmap, gfx_mode_t *mode);
/* Clones a pixmap, minus its index data, palette and driver-specific handles
** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to clone
**             (gfx_mode_t *) mode: The mode to be applied to the pixmap
** Returns   : (gfx_pixmap_t *) The clone
*/


gfx_pixmap_t *
gfx_pixmap_alloc_index_data(gfx_pixmap_t *pixmap);
/* Allocates the index_data field of a pixmap
** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to allocate for
** Returns   : (gfx_pixmap_t *) pixmap
*/

gfx_pixmap_t *
gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap);
/* Frees the index_data field of a pixmap
** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to modify
** Returns   : (gfx_pixmap_t *) pixmap
*/

gfx_pixmap_t *
gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode);
/* Allocates the data field of a pixmap
** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to allocate for
**             (gfx_mode_t *) mode: The mode the memory is to be allocated for
** Returns   : (gfx_pixmap_t *) pixmap
*/

gfx_pixmap_t *
gfx_pixmap_free_data(gfx_pixmap_t *pixmap);
/* Frees the memory allocated for a pixmap's data field
** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to modify
** Returns   : (gfx_pixmap_t *) pixmap
*/

void
gfx_free_pixmap(gfx_driver_t *driver, gfx_pixmap_t *pxm);
/* Frees all memory associated with a pixmap
** Parameters: (gfx_driver_t *) driver: The driver the pixmap is to be removed from
**             (gfx_pixmap_t *) pxm: The pixmap to free
** Returns   : (void)
*/

void
gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, point_t start, point_t end, int color);
/* Draws a line to a pixmap's index data buffer
** Parameters: (gfx_pixmap_t *) pxm: The pixmap to draw to
**             (point_t) start: Starting point of the line to draw
**             (point_t) end: End point of the line to draw
**             (int) color: The byte value to write
** Returns   : (void)
** Remember, this only draws to the /index/ buffer, not to the drawable buffer.
** The line is not clipped. Invalid x, y, x1, y1 values will result in memory corruption.
*/

void
gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth,
                     point_t start, point_t end, unsigned int color);
/* Draws a line to a linear pixel buffer
** Parameters: (byte *) buffer: Pointer to the start of the buffer to draw to
**             (int) linewidth: Number of bytes per pixel line in the buffer
**             (int) pixelwidth: Number of bytes per pixel
**             (point_t) start: Starting point of the line to draw
**             (point_t) end: End point of the line to draw
**             (rect_t) Coordinates: the line should be drawn to (must be clipped already)
**                      xl and yl describe relative offsets, as usual.
**             (unsigned int) color: The color to draw (only the lowest 8 * pixelwidth bits are relevant)
** Returns   : (void)
** This function assumes 1 <= pixelwidth <= 4
*/

void
gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color);
/* Draws a filled rectangular area to a pixmap's index buffer
** Parameters: (gfx_pixmap_t *) pxm: The pixmap to draw to
**             (rect_t) box: The box to fill
**             (int) color: The color to use for drawing
** Returns   : (void)
** This function only draws to the index buffer.
*/

void
gfx_copy_pixmap_box_i(gfx_pixmap_t *dest, gfx_pixmap_t *src, rect_t box);
/* Copies part of a pixmap to another pixmap, with clipping
** Parameters: (gfx_pixmap_t *) dest: The destination pixmap
**             (gfx_pixmap_t *) src: The source pixmap
**             (rect_t) box: The area to copy
** Returns   : (void)
*/

void
gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode, gfx_xlate_filter_t filter);
/* Translates a pixmap's index data to drawable graphics data
** Parameters: (gfx_pixmap_t *) pxm: The pixmap to translate
**             (gfx_mode_t *) mode: The mode according which to scale
**             (gfx_xlate_filter_t) filter: How to filter the data
** Returns   : (void)
*/

void
gfxr_antialiase(gfx_pixmap_t *pixmap, gfx_mode_t *mode, gfxr_antialiasing_t type);
/* Performs antialiasing on a pixmap
** Parameters: (gfx_pixmap_t *) pixmap: The pixmap to antialiase
**             (gfx_mode_t *) mode: The current mode
**             (gfxr_antialiasing_t) type: Antialiasing algorithm to use
** Returns   : (void)
*/

#define GFX_CROSSBLIT_FLAG_DATA_IS_HOMED (1<<0)
/* Means that the first byte in the visual data refers to the
** point corresponding to (dest.x, dest.y) */

int
gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority,
                     rect_t src_coords, rect_t dest_coords, byte *dest,
                     int dest_line_width, byte *priority_dest,
                     int priority_line_width, int priority_skip,
                     int flags);
/* Transfers the non-transparent part of a pixmap to a linear pixel buffer
** Parameters: (gfx_mode_t *) mode: The graphics mode of the target buffer
**             (gfx_pixmap_t *) pxm: The pixmap to transfer
**             (int priority): The pixmap's priority
**             (rect_t) src_coords: The source coordinates within the pixmap
**             (rect_t) dest_coords: The destination coordinates (no scaling)
**             (byte *) dest: Memory position of the upper left pixel of the
**                      linear pixel buffer
**             (int) dest_line_width: Byte offset of the very first pixel in the
**                                    second line of the linear pixel buffer,
**                                    relative to dest.
**             (byte *) priority_dest: Destination buffer for the pixmap's priority
**                                     values
**             (int) priority_line_width: Byte offset of the first pixel in the
**                                        second line of the priority buffer
**             (int) priority_skip: Amount of bytes allocated by each priority value
**             (int) flags: Any crossblit flags
** Returns   : (int) GFX_OK, or GFX_ERROR if the specified mode was invalid or unsupported
** A 'linear buffer' in this context means a data buffer containing an entire
** screen (visual or priority), with fixed offsets between each data row, and
** linear access.
*/

int
gfx_alloc_color(gfx_palette_t *pal, gfx_pixmap_color_t *color);
/* Allocates a color entry for the specified pixmap color
** Parameters: (gfx_palette_t *) pal: The palette structure the color should be allocated in
**             (gfx_pixmap_color_t *) color: The color to allocate
** Returns   : (int) GFX_ERROR if any error occured, GFX_OK if the color could be mapped to an
**                   existing color or a positive value if a new color was allocated in the
**                   palette.
*/

int
gfx_free_color(gfx_palette_t *pal, gfx_pixmap_color_t *color);
/* Frees the color entry allocated for the specified pixmap color
** Parameters: (gfx_palette_t *) pal: The palette structure the color was previously allocated in
**             (gfx_pixmap_color_t *) color: The color to free
** Returns   : (int) GFX_ERROR if any error occured, GFX_OK otherwise
*/

gfx_pixmap_t *
gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode);
/* Scales the index data associated with a pixmap
** Parameters: (gfx_pixmap_t *) pixmap: The pixmap whose index data should be scaled
**             (gfx_mode_t *) mode: The mode to scale it to
** Returns   : (gfx_pixmap_t *) pixmap
*/


#ifdef HAVE_ALPHA_EV6_SUPPORT

extern int axp_have_mvi; /* set to 1 iff the local system has the MVI instruction set extension */

void
alpha_mvi_crossblit_32(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_line,
                       int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel,
                       unsigned int alpha_test_mask, int alpha_shift);
/* Internal function for accellerated 32 bit cross-blitting on Alpha hardware */

void
alpha_mvi_crossblit_32_P(byte *dest, byte *src, int bytes_per_dest_line, int bytes_per_src_line,
                         int xl, int yl, byte *alpha, int bytes_per_alpha_line, int bytes_per_alpha_pixel,
                         unsigned int alpha_test_mask, int alpha_shift,
                         byte *priority_pos, int bytes_per_priority_line, int bytes_per_priority_pixel, int priority);
/* Internal function for accellerated 32 bit cross-blitting on Alpha hardware (with priority) */
#endif /* __alpha__ */


#endif /* !_GFX_TOOLS_H_ */