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
294
295
296
297
298
299
300
|
/* 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$
*
*/
/* SCI Resource library */
#ifndef SCI_GFX_GFX_RESOURCE_H
#define SCI_GFX_GFX_RESOURCE_H
#include "sci/gfx/gfx_system.h"
#include "sci/gfx/gfx_driver.h"
#include "common/rect.h"
namespace Common {
class File;
}
namespace Sci {
/*** Styles for pic0 drawing ***/
/* Dithering modes */
#define GFXR_DITHER_MODE_D16 0 /* Sierra SCI style */
#define GFXR_DITHER_MODE_F256 1 /* Flat color interpolation */
#define GFXR_DITHER_MODE_D256 2 /* 256 color dithering */
/* Dithering patterns */
#define GFXR_DITHER_PATTERN_SCALED 0 /* Dither per pixel on the 320x200 grid */
#define GFXR_DITHER_PATTERN_1 1 /* Dither per pixel on the target */
#define SCI_TITLEBAR_SIZE 10
#define DRAWPIC01_FLAG_FILL_NORMALLY 1
#define DRAWPIC01_FLAG_OVERLAID_PIC 2
#define DRAWPIC1_FLAG_MIRRORED 4
#define GFXR_AUX_MAP_SIZE (320*200)
#define GFX_SCI0_IMAGE_COLORS_NR 16
#define GFX_SCI0_PIC_COLORS_NR 256
#define GFX_SCI1_AMIGA_COLORS_NR 32
extern int sci0_palette;
/* (gfx_pic_0.c) The 16 EGA base colors */
extern Palette* gfx_sci0_image_pal[];
extern gfx_pixmap_color_t gfx_sci0_image_colors[][16];
/* (gfx_pic_0.c) The 256 interpolated colors (initialized when
** gfxr_init_pic() is called for the first time, or when gfxr_init_static_palette() is called)
*/
extern Palette* gfx_sci0_pic_colors;
struct gfxr_pic0_params_t {
gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */
gfx_brush_mode_t brush_mode;
};
struct gfxr_pic_t {
int ID; /* pic number (NOT resource ID, just number) */
gfx_mode_t *mode;
gfx_pixmap_t *visual_map;
gfx_pixmap_t *priority_map;
gfx_pixmap_t *control_map;
byte aux_map[GFXR_AUX_MAP_SIZE];
/* Auxiliary map details:
** Bit 0: Vis
** Bit 1: Pri
** Bit 2: Ctrl
** Bit 3-5: 'filled' (all three bits are set to 1)
*/
rect_t bounds;
void *undithered_buffer; /* copies visual_map->index_data before dithering */
int undithered_buffer_size;
int *priorityTable;
};
struct gfxr_loop_t {
int cels_nr;
gfx_pixmap_t **cels;
};
struct gfxr_view_t {
int ID;
int flags;
Palette *palette;
int loops_nr;
gfxr_loop_t *loops;
int translation[GFX_SCI0_IMAGE_COLORS_NR];
};
/* unscaled color index mode: Used in addition to a scaled mode
** to render the pic resource twice. See gfxr_remove_artifacts_pic0().
*/
extern gfx_mode_t mode_1x1_color_index;
void gfxr_init_static_palette();
/* Initializes the static 256 color palette
** Parameters: (void)
** Returns : (void)
*/
gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1);
/* Initializes a gfxr_pic_t for a specific mode
** Parameters: (gfx_mode_t *) mode: The specific graphics mode
** (int) ID: The ID to assign to the resulting pixmaps
** Returns : (gfxr_pic_t *) The allocated pic resource, or NULL on error.
** This function allocates memory for use by resource drawer functions.
*/
void gfxr_free_pic(gfxr_pic_t *pic);
/* Uninitializes a pic resource
** Parameters: (gfxr_pic_t *) pic: The pic to free
** Returns : (void)
*/
void gfxr_free_view(gfxr_view_t *view);
/* Frees all memory associated with a view
** Paremeters: (gfxr_view_t *) view: The view to free
** Returns : (void)
*/
/*********************/
/* SCI0 operations */
/*********************/
void gfxr_clear_pic0(gfxr_pic_t *pic, int titlebar_size);
/* Clears all pic buffers of one pic
** Parameters: (gfxr_pic_t) pic: The picture to clear
** (int) titlebar_size: How much space to reserve for the title bar
** Returns : (void)
** This function should be called before gfxr_draw_pic0, unless cumulative
** drawing is intended
*/
void gfxr_draw_pic01(gfxr_pic_t *pic, int fill_normally, int default_palette,
int size, byte *resource, gfxr_pic0_params_t *style, int resid, int sci1,
Palette *static_pal, Common::Rect portBounds);
/* Draws a pic resource (all formats prior to SCI1.1)
** Parameters: (gfxr_pic_t *) pic: The pic to draw to
** (int) fill_normally: If 1, the pic is drawn normally; if 0, all
** fill operations will fill with black
** (int) default_palette: The default palette to use for drawing
** (int) size: Resource size
** (byte *) resource: Pointer to the resource data
** (gfxr_pic0_params_t *) style: The drawing style
** (int) resid: The resource ID
** (int) sci1: Nonzero if SCI1
** (Palette *) static_pal: The static palette
** (int) static_pal_nr: Number of entries in static palette
** Returns : (void)
** The result is stored in gfxr_visual_map, gfxr_priority_map, and gfxr_control_map.
** The palette entry of gfxr_visual_map is never used.
** Note that the picture will not be drawn dithered; use gfxr_dither_pic0 for that.
*/
void gfxr_draw_pic11(gfxr_pic_t *pic, int fill_normally, int default_palette,
int size, byte *resource, gfxr_pic0_params_t *style, int resid,
Palette *static_pal, Common::Rect portBounds);
/* Draws a pic resource (SCI1.1)
** Parameters: (gfxr_pic_t *) pic: The pic to draw to
** (int) fill_normally: If 1, the pic is drawn normally; if 0, all
** fill operations will fill with black
** (int) default_palette: The default palette to use for drawing
** (int) size: Resource size
** (byte *) resource: Pointer to the resource data
** (gfxr_pic0_params_t *) style: The drawing style
** (int) resid: The resource ID
** (Palette *) static_pal: The static palette
** (int) static_pal_nr: Number of entries in static palette
** Returns : (void)
** The result is stored in gfxr_visual_map, gfxr_priority_map, and gfxr_control_map.
** The palette entry of gfxr_visual_map is never used.
** Note that the picture will not be drawn dithered; use gfxr_dither_pic0 for that.
*/
void gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src);
/* Removes artifacts from a scaled pic
** Parameters: (gfxr_pic_t *) dest: The scaled pic
** (gfxr_pic_t *) src: An unscaled pic
** Returns : (void)
** Using information from the (correctly rendered) src pic, this function implements
** some heuristics to remove artifacts from dest. Must be used before dither_pic0 is
** called, because it operates on the index buffer.
*/
void gfxr_dither_pic0(gfxr_pic_t *pic, int mode, int pattern);
/* Dithers a gfxr_visual_map
** Parameters: (gfxr_pic_t *) pic: The pic to dither
** (int) mode: One of GFXR_DITHER_MODE
** (int) pattern: One of GFXR_DITHER_PATTERN
** Returns : (void)
*/
gfxr_view_t *gfxr_draw_view0(int id, byte *resource, int size, int palette);
/* Calculates an SCI0 view
** Parameters: (int) id: Resource ID of the view
** (byte *) resource: Pointer to the resource to read
** (int) size: Size of the resource
** (int) palette: The palette to use
** Returns : (gfxr_view_t *) The resulting view
*/
gfx_pixmap_t *gfxr_draw_cursor(int id, byte *resource, int size, bool isSci01);
/* Calculates n SCI cursor
** Parameters: (int) id: The cursor's resource ID
** (byte *) resource: Pointer to the resource data
** (int) size: Resource size
** (bool) isSci01: Set to true to load a SCI1 cursor
** Returns : (gfx_pixmap_t *) A newly allocated pixmap containing an index
** color representation of the cursor
*/
/*********************/
/* SCI1 operations */
/*********************/
Palette *gfxr_read_pal1(int id, byte *resource, int size);
/* Reads an SCI1 palette
** Parameters: (int) id: Resource ID for the palette (or the view it was found in)
** (int *) colors_nr: Pointer to the variable the number of colors
** will be stored in
** (byte *) resource: Source data
** (int) size: Size of the memory block pointed to by resource
** Returns : (Palette *) *colors_nr Palette with the colors
*/
Palette *gfxr_read_pal1_amiga(Common::File &file);
/* Reads an SCI1 palette
** Parameters: (int *) colors_nr: Pointer to the variable the number of colors
** will be stored in
** (FILE *) f: Palette file
** Returns : (Palette *) Palette with the colors
*/
Palette *gfxr_read_pal11(int id, byte *resource, int size);
/* Reads an SCI1.1 palette
** Parameters: (int) id: Resource ID for the palette (or the view it was found in)
** (int *) colors_nr: Pointer to the variable the number of colors
** will be stored in
** (byte *) resource: Source data
** (int) size: Size of the memory block pointed to by resource
** Returns : (Palette *) Palette with the colors
*/
gfxr_view_t *gfxr_draw_view1(int id, byte *resource, int size, Palette *static_pal);
/* Calculates an SCI1 view
** Parameters: (int) id: Resource ID of the view
** (byte *) resource: Pointer to the resource to read
** (int) size: Size of the resource
** (Palette *) static_pal: The static palette
** (int) static_pal_nr: Number of entries in static palette
** Returns : (gfxr_view_t *) The resulting view
*/
gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, byte *cel_base, int size, gfxr_view_t *view, bool isAmiga, bool isSci11);
} // End of namespace Sci
#endif // SCI_GFX_GFX_RESOURCE_H
|