aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaweł Kołodziejski2009-02-21 11:53:27 +0000
committerPaweł Kołodziejski2009-02-21 11:53:27 +0000
commitf582debaa926297158a0baed9484a09153806060 (patch)
tree4df2b59fdea1af19c8cf077c5402e48b4f51a31a /engines
parentdb7073b15a063c6e4f683076bb25d413e3cd3a28 (diff)
downloadscummvm-rg350-f582debaa926297158a0baed9484a09153806060.tar.gz
scummvm-rg350-f582debaa926297158a0baed9484a09153806060.tar.bz2
scummvm-rg350-f582debaa926297158a0baed9484a09153806060.zip
formating
svn-id: r38686
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/gfx/resource/sci_pic_0.cpp597
1 files changed, 233 insertions, 364 deletions
diff --git a/engines/sci/gfx/resource/sci_pic_0.cpp b/engines/sci/gfx/resource/sci_pic_0.cpp
index 665ebf7314..246794a6d7 100644
--- a/engines/sci/gfx/resource/sci_pic_0.cpp
+++ b/engines/sci/gfx/resource/sci_pic_0.cpp
@@ -30,26 +30,26 @@
namespace Sci {
-#undef GFXR_DEBUG_PIC0 /* Enable to debug pic0 messages */
-#undef FILL_RECURSIVE_DEBUG /* Enable for verbose fill debugging */
+#undef GFXR_DEBUG_PIC0 // Enable to debug pic0 messages
+#undef FILL_RECURSIVE_DEBUG // Enable for verbose fill debugging
#define GFXR_PIC0_PALETTE_SIZE 40
#define GFXR_PIC0_NUM_PALETTES 4
#define INTERCOL(a, b) ((int) sqrt((((3.3 * (a))*(a)) + ((1.7 * (b))*(b))) / 5.0))
-/* Macro for color interpolation */
+// Macro for color interpolation
-#define SCI_PIC0_MAX_FILL 30 /* Number of times to fill before yielding to scheduler */
+#define SCI_PIC0_MAX_FILL 30 // Number of times to fill before yielding to scheduler
#define SCI0_MAX_PALETTE 2
int sci0_palette = 0;
-/* Copied from include/kernel.h */
+// Copied from include/kernel.h
#define SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr) ((((nr) == 0)? 0 : \
((first) + (((nr)-1) * (last - first)) / 14)))
-/* Default color maps */
+// Default color maps
gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLORS_NR] = {
{{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xaa},
{GFX_COLOR_SYSTEM, 0x00, 0xaa, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0xaa, 0xaa},
@@ -58,7 +58,7 @@ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLO
{GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0x55, 0xff},
{GFX_COLOR_SYSTEM, 0x55, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff},
{GFX_COLOR_SYSTEM, 0xff, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff},
- {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, /* "Normal" EGA */
+ {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x55}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, // "Normal" EGA
{{GFX_COLOR_SYSTEM, 0x00, 0x00, 0x00}, {GFX_COLOR_SYSTEM, 0x00, 0x00, 0xff},
@@ -68,9 +68,9 @@ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLO
{GFX_COLOR_SYSTEM, 0x55, 0x55, 0x55}, {GFX_COLOR_SYSTEM, 0x00, 0xbe, 0xff},
{GFX_COLOR_SYSTEM, 0x00, 0xce, 0x55}, {GFX_COLOR_SYSTEM, 0x55, 0xff, 0xff},
{GFX_COLOR_SYSTEM, 0xff, 0x9d, 0x8d}, {GFX_COLOR_SYSTEM, 0xff, 0x55, 0xff},
- {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x00}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, /* AGI Amiga-ish */
+ {GFX_COLOR_SYSTEM, 0xff, 0xff, 0x00}, {GFX_COLOR_SYSTEM, 0xff, 0xff, 0xff}}, // AGI Amiga-ish
- /* RGB and I intensities (former taken from the GIMP) */
+// RGB and I intensities (former taken from the GIMP)
#define GR 30
#define GG 59
#define GB 11
@@ -78,7 +78,7 @@ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLO
#define FULL (GR+GG+GB+GI)
-#define CC(x) (((x)*255)/FULL),(((x)*255)/FULL),(((x)*255)/FULL) /* Combines color intensities */
+#define CC(x) (((x)*255)/FULL),(((x)*255)/FULL),(((x)*255)/FULL) // Combines color intensities
{{GFX_COLOR_SYSTEM, CC(0) }, {GFX_COLOR_SYSTEM, CC(GB) },
{GFX_COLOR_SYSTEM, CC(GG) }, {GFX_COLOR_SYSTEM, CC(GB + GG) },
@@ -88,7 +88,7 @@ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLO
{GFX_COLOR_SYSTEM, CC(GG + GI) }, {GFX_COLOR_SYSTEM, CC(GB + GG + GI) },
{GFX_COLOR_SYSTEM, CC(GR + GI) }, {GFX_COLOR_SYSTEM, CC(GB + GR + GI) },
{GFX_COLOR_SYSTEM, CC(GG + GR + GI) }, {GFX_COLOR_SYSTEM, CC(GB + GG + GR + GI) }}
-}; /* Grayscale */
+}; // Grayscale
#undef GR
#undef GG
@@ -101,7 +101,7 @@ gfx_pixmap_color_t gfx_sci0_image_colors[SCI0_MAX_PALETTE+1][GFX_SCI0_IMAGE_COLO
#undef C3
#undef C4
-gfx_pixmap_color_t gfx_sci0_pic_colors[GFX_SCI0_PIC_COLORS_NR]; /* Initialized during initialization */
+gfx_pixmap_color_t gfx_sci0_pic_colors[GFX_SCI0_PIC_COLORS_NR]; // Initialized during initialization
static int _gfxr_pic0_colors_initialized = 0;
@@ -114,7 +114,7 @@ int fillmagc = 30000000;
/************************************/
#endif
-/* Color mapping used while scaling embedded views. */
+// Color mapping used while scaling embedded views.
gfx_pixmap_color_t embedded_view_colors[16] = {
{0x00, 0, 0, 0}, {0x11, 0, 0, 0}, {0x22, 0, 0, 0}, {0x33, 0, 0, 0},
{0x44, 0, 0, 0}, {0x55, 0, 0, 0}, {0x66, 0, 0, 0}, {0x77, 0, 0, 0},
@@ -122,8 +122,7 @@ gfx_pixmap_color_t embedded_view_colors[16] = {
{0xcc, 0, 0, 0}, {0xdd, 0, 0, 0}, {0xee, 0, 0, 0}, {0xff, 0, 0, 0}
};
-void
-gfxr_init_static_palette() {
+void gfxr_init_static_palette() {
if (!_gfxr_pic0_colors_initialized) {
for (int i = 0; i < 256; i++) {
gfx_sci0_pic_colors[i].global_index = GFX_COLOR_INDEX_UNMAPPED;
@@ -135,7 +134,7 @@ gfxr_init_static_palette() {
gfx_sci0_image_colors[sci0_palette][i >> 4].b);
}
//warning("Uncomment me after fixing sci0_palette changes to reset me");
- /* _gfxr_pic0_colors_initialized = 1; */
+ //_gfxr_pic0_colors_initialized = 1;
}
}
@@ -171,7 +170,7 @@ gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) {
pic->control_map->colors = gfx_sci0_image_colors[sci0_palette];
pic->control_map->colors_nr = GFX_SCI0_IMAGE_COLORS_NR;
- /* Initialize colors */
+ // Initialize colors
if (!sci1) {
pic->ID = ID;
gfxr_init_static_palette();
@@ -184,16 +183,12 @@ gfxr_init_pic(gfx_mode_t *mode, int ID, int sci1) {
return pic;
}
+// Pic rendering operations
-/****************************/
-/* Pic rendering operations */
-/****************************/
-
-void
-gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) {
+void gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) {
memset(pic->visual_map->index_data, 0x00, (320 * pic->mode->xfact * sci_titlebar_size * pic->mode->yfact));
memset(pic->visual_map->index_data + (320 * pic->mode->xfact * sci_titlebar_size * pic->mode->yfact),
- 0xff, pic->mode->xfact * 320 * pic->mode->yfact * (200 - sci_titlebar_size)); /* white */
+ 0xff, pic->mode->xfact * 320 * pic->mode->yfact * (200 - sci_titlebar_size)); // white
memset(pic->priority_map->index_data + (320 * pic->mode->xfact * sci_titlebar_size * pic->mode->yfact),
0x0, pic->mode->xfact * 320 * pic->mode->yfact * (200 - sci_titlebar_size));
memset(pic->priority_map->index_data, 0x0a, sci_titlebar_size * (pic->mode->yfact * 320 * pic->mode->xfact));
@@ -202,10 +197,10 @@ gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) {
}
-/*** Basic operations on the auxiliary buffer ***/
+//** Basic operations on the auxiliary buffer **
#define FRESH_PAINT 0x40
-/* freshly filled or near to something that is */
+// freshly filled or near to something that is
#define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \
linearend, nonlinearstart, linearmod, nonlinearmod, operation) \
@@ -226,8 +221,7 @@ gfxr_clear_pic0(gfxr_pic_t *pic, int sci_titlebar_size) {
}; \
buffer[linewidth * y + x] operation color;
-static void
-_gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int sci_titlebar_size) {
+static void _gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int sci_titlebar_size) {
int dx, dy, incrE, incrNE, d, finalx, finaly;
int x = line.x;
int y = line.y + sci_titlebar_size;
@@ -244,37 +238,36 @@ _gfxr_auxbuf_line_draw(gfxr_pic_t *pic, rect_t line, int color, int color2, int
if (dx > dy) {
if (finalx < x) {
- if (finaly < y) { /* llu == left-left-up */
+ if (finaly < y) { // llu == left-left-up
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, -1, -1, |=);
- } else { /* lld */
+ } else { // lld
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, -1, 1, |=);
}
- } else { /* x1 >= x */
- if (finaly < y) { /* rru */
+ } else { // x1 >= x
+ if (finaly < y) { // rru
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, 1, -1, |=);
- } else { /* rrd */
+ } else { // rrd
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, 1, 1, |=);
}
}
- } else { /* dx <= dy */
+ } else { // dx <= dy
if (finaly < y) {
- if (finalx < x) { /* luu */
+ if (finalx < x) { // luu
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, -1, -1, |=);
- } else { /* ruu */
+ } else { // ruu
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, -1, 1, |=);
}
- } else { /* y1 >= y */
- if (finalx < x) { /* ldd */
+ } else { // y1 >= y
+ if (finalx < x) { // ldd
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, 1, -1, |=);
- } else { /* rdd */
+ } else { // rdd
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, 1, 1, |=);
}
}
}
}
-static void
-_gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titlebar_size) {
+static void _gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titlebar_size) {
int dx, dy, incrE, incrNE, d, finalx, finaly;
int x = line.x;
int y = line.y + sci_titlebar_size;
@@ -291,29 +284,29 @@ _gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titleba
if (dx > dy) {
if (finalx < x) {
- if (finaly < y) { /* llu == left-left-up */
+ if (finaly < y) { // llu == left-left-up
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, -1, -1, &=);
- } else { /* lld */
+ } else { // lld
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, -1, 1, &=);
}
- } else { /* x1 >= x */
- if (finaly < y) { /* rru */
+ } else { // x1 >= x
+ if (finaly < y) { // rru
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, 1, -1, &=);
- } else { /* rrd */
+ } else { // rrd
LINEMACRO(x, y, dx, dy, x, y, finalx, dx, 1, 1, &=);
}
}
- } else { /* dx <= dy */
+ } else { // dx <= dy
if (finaly < y) {
- if (finalx < x) { /* luu */
+ if (finalx < x) { // luu
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, -1, -1, &=);
- } else { /* ruu */
+ } else { // ruu
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, -1, 1, &=);
}
- } else { /* y1 >= y */
- if (finalx < x) { /* ldd */
+ } else { // y1 >= y
+ if (finalx < x) { // ldd
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, 1, -1, &=);
- } else { /* rdd */
+ } else { // rdd
LINEMACRO(x, y, dy, dx, y, x, finaly, dy, 1, 1, &=);
}
}
@@ -322,20 +315,14 @@ _gfxr_auxbuf_line_clear(gfxr_pic_t *pic, rect_t line, int color, int sci_titleba
#undef LINEMACRO
-
#ifdef WITH_PIC_SCALING
-static void
-_gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) {
- /* Propagates all filled bits into the planes described by bitmask */
- unsigned long *data = (unsigned long *) pic->aux_map;
+static void _gfxr_auxbuf_propagate_changes(gfxr_pic_t *pic, int bitmask) {
+ // Propagates all filled bits into the planes described by bitmask
+ unsigned long *data = (unsigned long *)pic->aux_map;
unsigned long clearmask = 0x07070707;
- unsigned long andmask =
- (bitmask << 3)
- | (bitmask << (3 + 8))
- | (bitmask << (3 + 16))
- | (bitmask << (3 + 24));
+ unsigned long andmask = (bitmask << 3) | (bitmask << (3 + 8)) | (bitmask << (3 + 16)) | (bitmask << (3 + 24));
- if (sizeof(unsigned long) == 8) { /* UltraSparc, Alpha, newer MIPSens, etc */
+ if (sizeof(unsigned long) == 8) { // UltraSparc, Alpha, newer MIPSens, etc
andmask |= (andmask << 32);
clearmask |= (clearmask << 32);
}
@@ -359,12 +346,10 @@ _gfxr_auxbuf_tag_line(gfxr_pic_t *pic, int pos, int width) {
#if 0
// Unreferenced - removed
-static void
-_gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *max_y) {
- /* Tries to spread by approximating the first derivation of the border function.
- ** Draws to the current and the last line, thus taking up to twice as long as neccessary.
- ** Other than that, it's O(n^2)
- */
+static void _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *max_y) {
+ // Tries to spread by approximating the first derivation of the border function.
+ // Draws to the current and the last line, thus taking up to twice as long as neccessary.
+ // Other than that, it's O(n^2)
int intervals_nr = 0, old_intervals_nr;
int x, y, i, pos = 10 * 320;
@@ -386,7 +371,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma
#endif
for (y = 10; y < 200; y++) {
- int ivi = y & 1; /* InterVal Index: Current intervals; !ivi is the list of old ones */
+ int ivi = y & 1; // InterVal Index: Current intervals; !ivi is the list of old ones
int old_intervals_start_offset = 0;
int width = 0;
@@ -396,7 +381,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma
for (x = 0; x < 321; x++)
if (x < 320 && pic->aux_map[pos+x] & 0x10)
width++;
- else if (width) { /* Found one interval */
+ else if (width) { // Found one interval
int xl = x - width;
int xr = x - 1;
int done = 0;
@@ -419,7 +404,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma
else if (intervals[!ivi][i].xr < xl - 1) {
int o_xl = intervals[!ivi][i].xl;
int o_xr = intervals[!ivi][i].xr;
- if (o_xr == o_xl && !intervals[!ivi][i].tag) { /* thin bar */
+ if (o_xr == o_xl && !intervals[!ivi][i].tag) { // thin bar
memcpy(intervals[ivi] + intervals_nr, intervals[ivi] + intervals_nr - 1, sizeof(struct interval_struct));
memcpy(intervals[ivi] + intervals_nr - 1, intervals[!ivi] + i, sizeof(struct interval_struct));
intervals[!ivi][i].tag = 1;
@@ -428,9 +413,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma
}
old_intervals_start_offset = i;
- }
-
- else {
+ } else {
int k = i;
int old_xl = intervals[!ivi][i].xl;
int dwidth_l = abs(old_xl - xl);
@@ -446,7 +429,7 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma
old_xr = intervals[!ivi][k].xr;
dwidth_r = abs(old_xr - xr);
- /* Current line */
+ // Current line
write_left_width = (dwidth_l > xl) ? xl : dwidth_l;
_gfxr_auxbuf_tag_line(pic, pos + xl - write_left_width, write_left_width);
@@ -458,14 +441,14 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma
if (xr + write_right_width > *max_x)
*max_x = xr + write_right_width;
- /* Previous line */
+ // Previous line
write_left_width = (dwidth_l > old_xl) ? old_xl : dwidth_l;
write_right_width = (dwidth_r + old_xr > 319) ? 320 - old_xr : dwidth_r;
- if (i == k) { /* Only one predecessor interval */
+ if (i == k) { // Only one predecessor interval
_gfxr_auxbuf_tag_line(pic, pos - 320 + old_xl - write_left_width, write_left_width);
_gfxr_auxbuf_tag_line(pic, pos - 320 + old_xr, write_right_width);
- } else /* Fill entire line */
+ } else // Fill entire line
_gfxr_auxbuf_tag_line(pic, pos - 320 + old_xl - write_left_width, old_xr - old_xl
+ 1 + write_left_width + write_right_width);
@@ -509,8 +492,8 @@ _gfxr_auxbuf_spread(gfxr_pic_t *pic, int *min_x, int *min_y, int *max_x, int *ma
#endif
-/*** Regular drawing operations ***/
+/*** Regular drawing operations ***/
#define PATTERN_FLAG_RECTANGLE 0x10
#define PATTERN_FLAG_USE_PATTERN 0x20
@@ -548,9 +531,9 @@ enum {
PIC_SCI0_OPX_SET_PRIORITY_TABLE
};
-/* We use this so we can keep OPX handling in one switch.
- We simply add this constant to the op number if we're running an SCI1 game,
- and offset the OPX constants below correspondingly. */
+// We use this so we can keep OPX handling in one switch.
+// We simply add this constant to the op number if we're running an SCI1 game,
+// and offset the OPX constants below correspondingly.
#define SCI1_OP_OFFSET 42
enum {
@@ -569,14 +552,12 @@ void do_nothing(...) { }
#define p0printf do_nothing
#endif
-
enum {
- ELLIPSE_SOLID, /* Normal filled ellipse */
- ELLIPSE_OR /* color ORred to the buffer */
+ ELLIPSE_SOLID, // Normal filled ellipse
+ ELLIPSE_OR // color ORred to the buffer
};
-static void
-_gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y,
+static void _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y,
int rad_x, int rad_y, int color, int fillstyle) {
int xx = 0, yy = rad_y;
int i, x_i, y_i;
@@ -612,7 +593,7 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y,
offset1 += x - oldxx;
if (oldyy == 0)
- offset1 = 0; /* We never have to draw ellipses in the menu bar */
+ offset1 = 0; // We never have to draw ellipses in the menu bar
oldyy = yy;
@@ -641,11 +622,10 @@ _gfxr_fill_ellipse(gfxr_pic_t *pic, byte *buffer, int linewidth, int x, int y,
}
}
-static inline void
-_gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int plot,
+static inline void _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int plot,
int color, gfx_brush_mode_t brush_mode, int randseed) {
- /* yoffset 63680, offset 320, plot 1, color 34, brush_mode 0, randseed 432)*/
- /* Auxplot: Used by plot_aux_pattern to plot to visual and priority */
+ // yoffset 63680, offset 320, plot 1, color 34, brush_mode 0, randseed 432)*/
+ // Auxplot: Used by plot_aux_pattern to plot to visual and priority
int xc, yc;
int line_width = 320 * pic->mode->xfact;
int full_offset = (yoffset * pic->mode->yfact + offset) * pic->mode->xfact;
@@ -666,17 +646,16 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int
case GFX_BRUSH_MODE_ELLIPSES:
if (plot) {
int x = offset * pic->mode->xfact + ((pic->mode->xfact - 1) >> 1);
- int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1); /* Ouch! */
+ int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1);
- _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1,
- color, ELLIPSE_SOLID);
+ _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1, color, ELLIPSE_SOLID);
}
break;
case GFX_BRUSH_MODE_RANDOM_ELLIPSES:
if (plot) {
int x = offset * pic->mode->xfact + ((pic->mode->xfact - 1) >> 1);
- int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1); /* Ouch! */
+ int y = (yoffset / 320) * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1);
int sizex = pic->mode->xfact >> 1;
int sizey = pic->mode->yfact >> 1;
@@ -691,7 +670,7 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int
_gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1,
color, ELLIPSE_SOLID);
- srand(time(NULL)); /* Make sure we don't accidently forget to re-init the random number generator */
+ srand(time(NULL)); // Make sure we don't accidently forget to re-init the random number generator
}
break;
@@ -704,7 +683,7 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int
buffer[full_offset + xc] = color;
full_offset += line_width;
}
- srand(time(NULL)); /* Make sure we don't accidently forget to re-init the random number generator */
+ srand(time(NULL)); // Make sure we don't accidently forget to re-init the random number generator
}
break;
}
@@ -712,16 +691,13 @@ _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int offset, int
#define PLOT_AUX_PATTERN_NO_RANDOM -1
-static void
-_gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int random,
- int mask, int color, int priority, int control,
- gfx_brush_mode_t brush_mode, int map_nr) {
- /* Plots an appropriate pattern to the aux buffer and the control buffer,
- ** if mask & GFX_MASK_CONTROL
- ** random should be set to the random index, or -1 to disable
- */
+static void _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int random,
+ int mask, int color, int priority, int control, gfx_brush_mode_t brush_mode, int map_nr) {
+ // Plots an appropriate pattern to the aux buffer and the control buffer,
+ // if mask & GFX_MASK_CONTROL
+ // random should be set to the random index, or -1 to disable
- /* These circle offsets uniquely identify the circles used by Sierra: */
+ // These circle offsets uniquely identify the circles used by Sierra:
int circle_data[][8] = {
{0},
{1, 0},
@@ -733,14 +709,14 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int
{7, 7, 7, 6, 6, 5, 4, 2}
};
- /* 'Random' fill patterns, provided by Carl Muckenhoupt: */
+ // 'Random' fill patterns, provided by Carl Muckenhoupt:
byte random_data[32] = {
0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2, 0x82, 0x09, 0x0a, 0x22,
0x12, 0x10, 0x42, 0x14, 0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10,
0x22, 0xa8, 0x14, 0x24, 0x00, 0x50, 0x24, 0x04
};
- /* 'Random' fill offsets, provided by Carl Muckenhoupt: */
+ // 'Random' fill offsets, provided by Carl Muckenhoupt:
byte random_offset[128] = {
0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48,
0x60, 0xbd, 0x89, 0x05, 0x0a, 0xf4, 0x7d, 0x7d,
@@ -793,7 +769,8 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int
offset = circle_data[size][abs(i)];
height = width = (offset << 1) + 1;
offset = -offset;
- } else height = width - 1;
+ } else
+ height = width - 1;
if (random == PLOT_AUX_PATTERN_NO_RANDOM) {
@@ -804,54 +781,46 @@ _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int circle, int
for (j = x; j < x + width; j++)
pic->aux_map[yoffset + offset + j] |= mask;
- } else { /* Semi-Random! */
+ } else { // Semi-Random!
for (j = 0; j < height; j++) {
if (random_data[random_index >> 3] & (0x80 >> (random_index & 7))) {
- /* The 'seemingly' random decision */
+ // The 'seemingly' random decision
if (mask & GFX_MASK_CONTROL)
pic->control_map->index_data[yoffset + x + offset + j] = control;
pic->aux_map[yoffset + x + offset + j] |= mask;
if (mask & GFX_MASK_VISUAL)
- _gfxr_auxplot_brush(pic, pic->visual_map->index_data,
- yoffset, x + offset + j,
+ _gfxr_auxplot_brush(pic, pic->visual_map->index_data, yoffset, x + offset + j,
1, color, brush_mode, random_index + x);
if (mask & GFX_MASK_PRIORITY)
- _gfxr_auxplot_brush(pic, pic->priority_map->index_data,
- yoffset, x + offset + j,
+ _gfxr_auxplot_brush(pic, pic->priority_map->index_data, yoffset, x + offset + j,
1, priority, brush_mode, random_index + x);
} else {
if (mask & GFX_MASK_VISUAL)
- _gfxr_auxplot_brush(pic, pic->visual_map->index_data,
- yoffset, x + offset + j,
+ _gfxr_auxplot_brush(pic, pic->visual_map->index_data, yoffset, x + offset + j,
0, color, brush_mode, random_index + x);
if (mask & GFX_MASK_PRIORITY)
- _gfxr_auxplot_brush(pic, pic->priority_map->index_data,
- yoffset, x + offset + j,
+ _gfxr_auxplot_brush(pic, pic->priority_map->index_data, yoffset, x + offset + j,
0, priority, brush_mode, random_index + x);
}
random_index = (random_index + 1) & 0xff;
}
}
-
yoffset += 320;
}
}
-
-static void
-_gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int control, int drawenable,
- int pattern_code, int pattern_size, int pattern_nr, gfx_brush_mode_t brush_mode,
- int sci_titlebar_size) {
+static void _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int control, int drawenable,
+ int pattern_code, int pattern_size, int pattern_nr, gfx_brush_mode_t brush_mode, int sci_titlebar_size) {
int xsize = (pattern_size + 1) * pic->mode->xfact - 1;
int ysize = (pattern_size + 1) * pic->mode->yfact - 1;
int scaled_x, scaled_y;
rect_t boundaries;
- int max_x = (pattern_code & PATTERN_FLAG_RECTANGLE) ? 318 : 319; /* Rectangles' width is size+1 */
+ int max_x = (pattern_code & PATTERN_FLAG_RECTANGLE) ? 318 : 319; // Rectangles' width is size+1
p0printf(stderr, "Pattern at (%d,%d) size %d, rand=%d, code=%02x\n", x, y, pattern_size, pattern_nr, pattern_code);
@@ -885,24 +854,18 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c
scaled_y = (200 * pic->mode->yfact) - 1 - ysize;
if (pattern_code & PATTERN_FLAG_RECTANGLE) {
- /* Rectangle */
+ // Rectangle
boundaries.x = scaled_x - xsize;
boundaries.y = scaled_y - ysize;
boundaries.xl = ((xsize + 1) << 1) + 1;
boundaries.yl = (ysize << 1) + 1;
-
if (pattern_code & PATTERN_FLAG_USE_PATTERN) {
- _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0, pattern_nr,
- drawenable, color, priority,
+ _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0, pattern_nr, drawenable, color, priority,
control, brush_mode, GFX_MASK_CONTROL);
} else {
-
- _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0,
- PLOT_AUX_PATTERN_NO_RANDOM,
- drawenable, 0, 0, control,
- GFX_BRUSH_MODE_SCALED,
- GFX_MASK_CONTROL);
+ _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 0, PLOT_AUX_PATTERN_NO_RANDOM, drawenable, 0, 0, control,
+ GFX_BRUSH_MODE_SCALED, GFX_MASK_CONTROL);
if (drawenable & GFX_MASK_VISUAL)
gfx_draw_box_pixmap_i(pic->visual_map, boundaries, color);
@@ -912,55 +875,38 @@ _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int priority, int c
}
} else {
- /* Circle */
+ // Circle
if (pattern_code & PATTERN_FLAG_USE_PATTERN) {
- _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, pattern_nr,
- drawenable, color, priority,
+ _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, pattern_nr, drawenable, color, priority,
control, brush_mode, GFX_MASK_CONTROL);
} else {
-
- _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1,
- PLOT_AUX_PATTERN_NO_RANDOM,
- drawenable, 0, 0, control,
- GFX_BRUSH_MODE_SCALED,
- GFX_MASK_CONTROL);
+ _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, PLOT_AUX_PATTERN_NO_RANDOM,
+ drawenable, 0, 0, control, GFX_BRUSH_MODE_SCALED, GFX_MASK_CONTROL);
if (pic->mode->xfact == 1 && pic->mode->yfact == 1) {
-
if (drawenable & GFX_MASK_VISUAL)
- _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1,
- PLOT_AUX_PATTERN_NO_RANDOM,
- drawenable, 0, 0, color,
- GFX_BRUSH_MODE_SCALED,
- GFX_MASK_VISUAL);
+ _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, PLOT_AUX_PATTERN_NO_RANDOM,
+ drawenable, 0, 0, color, GFX_BRUSH_MODE_SCALED, GFX_MASK_VISUAL);
if (drawenable & GFX_MASK_PRIORITY)
- _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1,
- PLOT_AUX_PATTERN_NO_RANDOM,
- drawenable, 0, 0, priority,
- GFX_BRUSH_MODE_SCALED,
- GFX_MASK_PRIORITY);
+ _gfxr_plot_aux_pattern(pic, x, y, pattern_size, 1, PLOT_AUX_PATTERN_NO_RANDOM,
+ drawenable, 0, 0, priority, GFX_BRUSH_MODE_SCALED, GFX_MASK_PRIORITY);
} else {
-
if (drawenable & GFX_MASK_VISUAL)
_gfxr_fill_ellipse(pic, pic->visual_map->index_data, 320 * pic->mode->xfact,
- scaled_x, scaled_y, xsize, ysize,
- color, ELLIPSE_SOLID);
+ scaled_x, scaled_y, xsize, ysize, color, ELLIPSE_SOLID);
if (drawenable & GFX_MASK_PRIORITY)
_gfxr_fill_ellipse(pic, pic->priority_map->index_data, 320 * pic->mode->xfact,
- scaled_x, scaled_y, xsize, ysize,
- priority, ELLIPSE_SOLID);
+ scaled_x, scaled_y, xsize, ysize, priority, ELLIPSE_SOLID);
}
}
}
}
-
-static inline void
-_gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int priority, int drawenable) {
+static inline void _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int priority, int drawenable) {
Common::Point start;
Common::Point end;
@@ -970,8 +916,7 @@ _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int
end.y = ey;
if (ex >= pic->visual_map->index_xl || ey >= pic->visual_map->index_yl || x < 0 || y < 0) {
- error("While drawing pic0: INVALID LINE %d,%d,%d,%d\n",
- start.x, start.y, end.x, end.y);
+ error("While drawing pic0: INVALID LINE %d,%d,%d,%d\n", start.x, start.y, end.x, end.y);
return;
}
@@ -983,25 +928,21 @@ _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color, int
}
-static void
-_gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
- int priority, int control, int drawenable, int line_mode,
- int cmd, int sci_titlebar_size) {
+static void _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
+ int priority, int control, int drawenable, int line_mode, int cmd, int sci_titlebar_size) {
int scale_x = pic->mode->xfact;
int scale_y = pic->mode->yfact;
int xc, yc;
rect_t line;
int mask;
- int partially_white = (drawenable & GFX_MASK_VISUAL)
- && (((color & 0xf0) == 0xf0) || ((color & 0x0f) == 0x0f));
+ int partially_white = (drawenable & GFX_MASK_VISUAL) && (((color & 0xf0) == 0xf0) || ((color & 0x0f) == 0x0f));
line.x = x;
line.y = y;
line.xl = ex - x;
line.yl = ey - y;
- if (x > 319 || y > 199 || x < 0 || y < 0
- || ex > 319 || ey > 199 || ex < 0 || ey < 0) {
+ if (x > 319 || y > 199 || x < 0 || y < 0 || ex > 319 || ey > 199 || ex < 0 || ey < 0) {
GFXWARN("While building pic: Attempt to draw line (%d,%d) to (%d,%d): cmd was %d\n", x, y, ex, ey, cmd);
return;
}
@@ -1010,19 +951,12 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
ey += sci_titlebar_size;
if (drawenable & GFX_MASK_CONTROL) {
-
p0printf(" ctl:%x", control);
gfx_draw_line_pixmap_i(pic->control_map, Common::Point(x, y), Common::Point(x + line.xl, y + line.yl), control);
}
-
- /* Calculate everything that is changed to SOLID */
- mask = drawenable &
- (
- ((color != 0xff) ? 1 : 0)
- | ((priority) ? 2 : 0)
- | ((control) ? 4 : 0)
- );
+ // Calculate everything that is changed to SOLID
+ mask = drawenable & (((color != 0xff) ? 1 : 0) | ((priority) ? 2 : 0) | ((control) ? 4 : 0));
if (mask) {
int mask2 = mask;
@@ -1031,13 +965,8 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
_gfxr_auxbuf_line_draw(pic, line, mask, mask2, sci_titlebar_size);
}
- /* Calculate everything that is changed to TRANSPARENT */
- mask = drawenable &
- (
- ((color == 0xff) ? 1 : 0)
- | ((!priority) ? 2 : 0)
- | ((!control) ? 4 : 0)
- );
+ // Calculate everything that is changed to TRANSPARENT
+ mask = drawenable & (((color == 0xff) ? 1 : 0) | ((!priority) ? 2 : 0) | ((!control) ? 4 : 0));
if (mask)
_gfxr_auxbuf_line_clear(pic, line, ~mask, sci_titlebar_size);
@@ -1053,7 +982,7 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
if (drawenable & GFX_MASK_PRIORITY)
p0printf(" pri:%x", priority);
- if (line_mode == GFX_LINE_MODE_FINE) { /* Adjust lines to extend over the full visual */
+ if (line_mode == GFX_LINE_MODE_FINE) { // Adjust lines to extend over the full visual
x = (x * ((320 + 1) * scale_x - 1)) / (320 * scale_x);
y = (y * ((200 + 1) * scale_y - 1)) / (200 * scale_y);
ex = (ex * ((320 + 1) * scale_x - 1)) / (320 * scale_x);
@@ -1061,7 +990,7 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
_gfxr_draw_subline(pic, x, y, ex, ey, color, priority, drawenable);
} else {
- if (x == ex && y == ey) { /* Just one single point? */
+ if (x == ex && y == ey) { // Just one single point?
rect_t drawrect;
drawrect.x = x;
drawrect.y = y;
@@ -1088,30 +1017,22 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
}
for (xc = 0; xc < width; xc++)
- _gfxr_draw_subline(pic,
- x + xc + x_offset, y + y_offset,
- ex + xc + x_offset, ey + y_offset,
+ _gfxr_draw_subline(pic, x + xc + x_offset, y + y_offset, ex + xc + x_offset, ey + y_offset,
color, priority, drawenable);
if (height > 0)
for (xc = 0; xc < width; xc++)
- _gfxr_draw_subline(pic,
- x + xc + x_offset, y + height - 1 + y_offset,
- ex + xc + x_offset, ey + height - 1 + y_offset,
- color, priority, drawenable);
+ _gfxr_draw_subline(pic, x + xc + x_offset, y + height - 1 + y_offset,
+ ex + xc + x_offset, ey + height - 1 + y_offset, color, priority, drawenable);
if (height > 1) {
for (yc = 1; yc < height - 1; yc++)
- _gfxr_draw_subline(pic,
- x + x_offset, y + yc + y_offset,
- ex + x_offset, ey + yc + y_offset,
+ _gfxr_draw_subline(pic, x + x_offset, y + yc + y_offset, ex + x_offset, ey + yc + y_offset,
color, priority, drawenable);
if (width > 0)
for (yc = 1; yc < height - 1; yc++)
- _gfxr_draw_subline(pic,
- x + width - 1 + x_offset, y + yc + y_offset,
- ex + width - 1 + x_offset, ey + yc + y_offset,
- color, priority, drawenable);
+ _gfxr_draw_subline(pic, x + width - 1 + x_offset, y + yc + y_offset,
+ ex + width - 1 + x_offset, ey + yc + y_offset, color, priority, drawenable);
}
}
}
@@ -1122,26 +1043,26 @@ _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int color,
#define IS_FILL_BOUNDARY(x) (((x) & legalmask) != legalcolor)
-
#ifdef WITH_PIC_SCALING
#define TEST_POINT(xx, yy) \
- if (pic->aux_map[(yy)*320 + (xx)] & FRESH_PAINT) { \
- mpos = (((yy) * 320 * pic->mode->yfact) + (xx)) * pic->mode->xfact; \
- for (iy = 0; iy < pic->mode->yfact; iy++) { \
- for (ix = 0; ix < pic->mode->xfact; ix++) \
- if (!IS_FILL_BOUNDARY(test_map[mpos + ix])) { \
- *x = ix + (xx) * pic->mode->xfact; \
- *y = iy + (yy) * pic->mode->yfact; \
- return 0; \
- } \
- mpos += linewidth; \
- } \
- }
-
-static inline int /* returns -1 on failure, 0 on success */
-_gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_y, int x_320,
+ if (pic->aux_map[(yy) * 320 + (xx)] & FRESH_PAINT) { \
+ mpos = (((yy) * 320 * pic->mode->yfact) + (xx)) * pic->mode->xfact; \
+ for (iy = 0; iy < pic->mode->yfact; iy++) { \
+ for (ix = 0; ix < pic->mode->xfact; ix++) { \
+ if (!IS_FILL_BOUNDARY(test_map[mpos + ix])) { \
+ *x = ix + (xx) * pic->mode->xfact; \
+ *y = iy + (yy) * pic->mode->yfact; \
+ return 0; \
+ } \
+ mpos += linewidth; \
+ } \
+ } \
+ }
+
+static inline int _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_y, int x_320,
int y_200, int color, int drawenable, int *x, int *y) {
+ // returns -1 on failure, 0 on success
int linewidth = pic->mode->xfact * 320;
int mpos, ix, iy;
int size_x = (max_x - min_x + 1) >> 1;
@@ -1162,12 +1083,12 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_
if (drawenable & GFX_MASK_VISUAL) {
test_map = pic->visual_map->index_data;
- if ((color & 0xf) == 0xf /* When dithering with white, do more
- ** conservative checks */
+ if ((color & 0xf) == 0xf // When dithering with white, do more
+ // conservative checks
|| (color & 0xf0) == 0xf0)
legalcolor = 0xff;
else
- legalcolor = 0xf0; /* Only check the second color */
+ legalcolor = 0xf0; // Only check the second color
legalmask = legalcolor;
} else if (drawenable & GFX_MASK_PRIORITY) {
@@ -1176,8 +1097,8 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_
legalmask = 0xf;
} else return -3;
- TEST_POINT(x_320, y_200); /* Most likely candidate */
- TEST_POINT(mid_x, mid_y); /* Second most likely candidate */
+ TEST_POINT(x_320, y_200); // Most likely candidate
+ TEST_POINT(mid_x, mid_y); // Second most likely candidate
for (size = 1; size <= max_size; size++) {
int i;
@@ -1208,7 +1129,7 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_
} // End of namespace Sci
-/* Now include the actual filling code (with scaling support) */
+// Now include the actual filling code (with scaling support)
#define FILL_FUNCTION _gfxr_fill_any
#define FILL_FUNCTION_RECURSIVE _gfxr_fill_any_recursive
#define AUXBUF_FILL_HELPER _gfxr_auxbuf_fill_any_recursive
@@ -1224,11 +1145,11 @@ _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_x, int max_
namespace Sci {
-#endif /* defined(WITH_PIC_SCALING) */
+#endif // defined(WITH_PIC_SCALING)
} // End of namespace Sci
-/* Include again, but this time without support for scaling */
+// Include again, but this time without support for scaling
#define FILL_FUNCTION _gfxr_fill_1
#define FILL_FUNCTION_RECURSIVE _gfxr_fill_1_recursive
#define AUXBUF_FILL_HELPER _gfxr_auxbuf_fill_1_recursive
@@ -1243,35 +1164,34 @@ namespace Sci {
namespace Sci {
#define GET_ABS_COORDS(x, y) \
- temp = *(resource + pos++); \
- x = *(resource + pos++); \
- y = *(resource + pos++); \
- x |= (temp & 0xf0) << 4; \
- y |= (temp & 0x0f) << 8;
+ temp = *(resource + pos++); \
+ x = *(resource + pos++); \
+ y = *(resource + pos++); \
+ x |= (temp & 0xf0) << 4; \
+ y |= (temp & 0x0f) << 8;
#define GET_REL_COORDS(x, y) \
- temp = *(resource + pos++); \
- if (temp & 0x80) \
- x -= ((temp >> 4) & 0x7); \
- else \
- x += (temp >> 4); \
+ temp = *(resource + pos++); \
+ if (temp & 0x80) \
+ x -= ((temp >> 4) & 0x7); \
+ else \
+ x += (temp >> 4); \
\
- if (temp & 0x08) \
- y -= (temp & 0x7); \
- else \
- y += (temp & 0x7);
+ if (temp & 0x08) \
+ y -= (temp & 0x7); \
+ else \
+ y += (temp & 0x7);
#define GET_MEDREL_COORDS(oldx, oldy) \
- temp = *(resource + pos++); \
- if (temp & 0x80) \
- y = oldy - (temp & 0x7f); \
- else \
- y = oldy + temp; \
- x = oldx + *((signed char *) resource + pos++);
+ temp = *(resource + pos++); \
+ if (temp & 0x80) \
+ y = oldy - (temp & 0x7f); \
+ else \
+ y = oldy + temp; \
+ x = oldx + *((signed char *) resource + pos++);
-inline static void
-check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r, byte u, byte d) {
+inline static void check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r, byte u, byte d) {
if (*dest == legalcolor) {
if (*srcp == legalcolor)
return;
@@ -1302,9 +1222,7 @@ check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, byte l, byte r
}
}
-
-void
-gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) {
+void gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) {
int x_320, y_200;
int bound_x = dest->mode->xfact;
int bound_y = dest->mode->yfact;
@@ -1315,7 +1233,6 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) {
assert(src->mode->yfact == 1);
if (bound_x == 1 && bound_y == 1) {
- /* D'Oh! */
GFXWARN("attempt to remove artifacts from unscaled pic");
return;
}
@@ -1329,11 +1246,9 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) {
for (sub_y = 0; sub_y < bound_y; sub_y++) {
for (sub_x = 0; sub_x < bound_x; sub_x++) {
- check_and_remove_artifact(dest->visual_map->index_data + write_offset,
- src_visualp, (int)0xff,
+ check_and_remove_artifact(dest->visual_map->index_data + write_offset, src_visualp, (int)0xff,
(byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199));
- check_and_remove_artifact(dest->priority_map->index_data + write_offset,
- src_priorityp, 0,
+ check_and_remove_artifact(dest->priority_map->index_data + write_offset, src_priorityp, 0,
(byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199));
++write_offset;
}
@@ -1345,10 +1260,7 @@ gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src) {
}
-static void
-view_transparentize(gfx_pixmap_t *view, byte *pic_index_data,
- int posx, int posy,
- int width, int height) {
+static void view_transparentize(gfx_pixmap_t *view, byte *pic_index_data, int posx, int posy, int width, int height) {
int i, j;
for (i = 0;i < width;i++)
@@ -1360,17 +1272,12 @@ view_transparentize(gfx_pixmap_t *view, byte *pic_index_data,
}
}
-extern gfx_pixmap_t *
- gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored);
-extern gfx_pixmap_t *
- gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game);
-extern void
- _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp);
-
-void
-gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
- byte *resource, gfxr_pic0_params_t *style, int resid, int sci1,
- gfx_pixmap_color_t *static_pal, int static_pal_nr) {
+extern gfx_pixmap_t *gfxr_draw_cel0(int id, int loop, int cel, byte *resource, int size, gfxr_view_t *view, int mirrored);
+extern gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *resource, int size, gfxr_view_t *view, int amiga_game);
+extern void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_line_width, int xl, int yl, int bpp);
+
+void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource,
+ gfxr_pic0_params_t *style, int resid, int sci1, gfx_pixmap_color_t *static_pal, int static_pal_nr) {
const int default_palette_table[GFXR_PIC0_PALETTE_SIZE] = {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0x88,
@@ -1408,15 +1315,15 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
#ifdef FILL_RECURSIVE_DEBUG
fillmagc = atoi(getenv("FOO"));
fillc = atoi(getenv("FOO2"));
-#endif /* FILL_RECURSIVE_DEBUG */
+#endif
- /* Initialize palette */
+ // Initialize palette
for (int i = 0; i < GFXR_PIC0_NUM_PALETTES; i++)
memcpy(palette[i], default_palette_table, sizeof(int) * GFXR_PIC0_PALETTE_SIZE);
memcpy(priority_table, default_priority_table, sizeof(int) * GFXR_PIC0_PALETTE_SIZE);
- /* Main loop */
+ // Main loop
while (pos < size) {
op = *(resource + pos++);
@@ -1438,25 +1345,24 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
color = palette[pal][index];
- } else color = *(resource + pos++);
+ } else
+ color = *(resource + pos++);
p0printf(" color <- %02x [%d/%d]\n", color, pal, index);
drawenable |= GFX_MASK_VISUAL;
goto end_op_loop;
-
case PIC_OP_DISABLE_VISUAL:
p0printf("Disable visual @%d\n", pos);
drawenable &= ~GFX_MASK_VISUAL;
goto end_op_loop;
-
case PIC_OP_SET_PRIORITY:
p0printf("Set priority @%d\n", pos);
if (!sci1) {
pal = *(resource + pos++);
index = pal % GFXR_PIC0_PALETTE_SIZE;
- pal /= GFXR_PIC0_PALETTE_SIZE; /* Ignore pal */
+ pal /= GFXR_PIC0_PALETTE_SIZE; // Ignore pal
priority = priority_table[index];
} else priority = *(resource + pos++);
@@ -1465,13 +1371,11 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
drawenable |= GFX_MASK_PRIORITY;
goto end_op_loop;
-
case PIC_OP_DISABLE_PRIORITY:
p0printf("Disable priority @%d\n", pos);
drawenable &= ~GFX_MASK_PRIORITY;
goto end_op_loop;
-
case PIC_OP_SHORT_PATTERNS:
p0printf("Short patterns @%d\n", pos);
if (pattern_code & PATTERN_FLAG_USE_PATTERN) {
@@ -1497,7 +1401,6 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
goto end_op_loop;
-
case PIC_OP_MEDIUM_LINES:
p0printf("Medium lines @%d\n", pos);
GET_ABS_COORDS(oldx, oldy);
@@ -1517,7 +1420,6 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
goto end_op_loop;
-
case PIC_OP_LONG_LINES:
p0printf("Long lines @%d\n", pos);
GET_ABS_COORDS(oldx, oldy);
@@ -1530,7 +1432,6 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
goto end_op_loop;
-
case PIC_OP_SHORT_LINES:
p0printf("Short lines @%d\n", pos);
GET_ABS_COORDS(oldx, oldy);
@@ -1545,17 +1446,15 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
goto end_op_loop;
-
case PIC_OP_FILL:
p0printf("Fill @%d\n", pos);
while (*(resource + pos) < PIC_OP_FIRST) {
- /*fprintf(stderr,"####################\n"); */
+ //fprintf(stderr,"####################\n");
GET_ABS_COORDS(x, y);
p0printf("Abs coords %d,%d\n", x, y);
- /*fprintf(stderr,"C=(%d,%d)\n", x, y + sci_titlebar_size);*/
+ //fprintf(stderr,"C=(%d,%d)\n", x, y + sci_titlebar_size);
#ifdef WITH_PIC_SCALING
- if (pic->mode->xfact > 1
- || pic->mode->yfact > 1)
+ if (pic->mode->xfact > 1 || pic->mode->yfact > 1)
_gfxr_fill_any(pic, x, y + sci_titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY) ?
color : 0, priority, control, drawenable, sci_titlebar_size);
@@ -1605,18 +1504,16 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
return;
}
--fillmagc;
-#endif /* GFXR_DEBUG_PIC0 */
+#endif // GFXR_DEBUG_PIC0
}
goto end_op_loop;
-
case PIC_OP_SET_PATTERN:
p0printf("Set pattern @%d\n", pos);
pattern_code = (*(resource + pos++));
pattern_size = pattern_code & 0x07;
goto end_op_loop;
-
case PIC_OP_ABSOLUTE_PATTERN:
p0printf("Absolute pattern @%d\n", pos);
while (*(resource + pos) < PIC_OP_FIRST) {
@@ -1632,7 +1529,6 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
goto end_op_loop;
-
case PIC_OP_SET_CONTROL:
p0printf("Set control @%d\n", pos);
control = (*(resource + pos++)) & 0xf;
@@ -1673,12 +1569,12 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
goto end_op_loop;
-
case PIC_OP_OPX:
opx = *(resource + pos++);
p0printf("OPX: ");
- if (sci1) opx += SCI1_OP_OFFSET; /* See comment at the definition of SCI1_OP_OFFSET. */
+ if (sci1)
+ opx += SCI1_OP_OFFSET; // See comment at the definition of SCI1_OP_OFFSET.
switch (opx) {
@@ -1701,7 +1597,6 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
}
goto end_op_loop;
-
case PIC_SCI0_OPX_SET_PALETTE:
p0printf("Set palette @%d\n", pos);
pal = *(resource + pos++);
@@ -1735,25 +1630,22 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
pos += 41;
goto end_op_loop;
-
case PIC_SCI0_OPX_MONO1:
case PIC_SCI0_OPX_MONO3:
++pos;
p0printf("Monochrome opx %d @%d\n", opx, pos);
goto end_op_loop;
-
case PIC_SCI0_OPX_MONO2:
- case PIC_SCI0_OPX_MONO4: /* Monochrome ops: Ignored by us */
+ case PIC_SCI0_OPX_MONO4: // Monochrome ops: Ignored by us
p0printf("Monochrome opx %d @%d\n", opx, pos);
goto end_op_loop;
-
case PIC_SCI0_OPX_EMBEDDED_VIEW:
case PIC_SCI1_OPX_EMBEDDED_VIEW: {
int posx, posy;
int bytesize;
- /* byte *vismap = pic->visual_map->index_data; */
+ //byte *vismap = pic->visual_map->index_data;
int nodraw = 0;
gfx_pixmap_t *view;
@@ -1761,11 +1653,9 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
p0printf("Embedded view @%d\n", pos);
- /* Set up mode structure for resizing the view */
- mode = gfx_new_mode(
- pic->visual_map->index_xl / 320,
- pic->visual_map->index_yl / 200,
- 1, /* 1bpp, which handles masks and the rest for us */
+ // Set up mode structure for resizing the view
+ mode = gfx_new_mode(pic->visual_map->index_xl / 320,
+ pic->visual_map->index_yl / 200, 1, // 1bpp, which handles masks and the rest for us
0, 0, 0, 0, 0, 0, 0, 0, 16, 0);
GET_ABS_COORDS(posx, posy);
@@ -1775,30 +1665,25 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
if (!sci1 && !nodraw)
view = gfxr_draw_cel0(-1, -1, -1, resource + pos, bytesize, NULL, 0);
else
- view = gfxr_draw_cel1(-1, -1, -1, 0, resource + pos, bytesize, NULL,
- static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR);
+ view = gfxr_draw_cel1(-1, -1, -1, 0, resource + pos, bytesize, NULL, static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR);
pos += bytesize;
- if (nodraw) continue;
- p0printf("(%d, %d)-(%d, %d)\n",
- posx,
- posy,
- posx + view->index_xl,
- posy + view->index_yl);
-
- /* we can only safely replace the palette if it's static
- *if it's not for some reason, we should die
- */
+ if (nodraw)
+ continue;
+ p0printf("(%d, %d)-(%d, %d)\n", posx, posy, posx + view->index_xl, posy + view->index_yl);
+
+ // we can only safely replace the palette if it's static
+ // *if it's not for some reason, we should die
+
if (!(view->flags & GFX_PIXMAP_FLAG_EXTERNAL_PALETTE) && !sci1) {
sciprintf("gfx_draw_pic0(): can't set a non-static palette for an embedded view");
}
- /* For SCI0, use special color mapping to copy the low
- ** nibble of the color index to the high
- ** nibble.
- */
+ // For SCI0, use special color mapping to copy the low
+ // nibble of the color index to the high nibble.
+
if (sci1) {
if (static_pal_nr == GFX_SCI1_AMIGA_COLORS_NR) {
- /* Assume Amiga game */
+ // Assume Amiga game
pic->visual_map->colors = static_pal;
pic->visual_map->colors_nr = static_pal_nr;
pic->visual_map->flags |= GFX_PIXMAP_FLAG_EXTERNAL_PALETTE;
@@ -1808,25 +1693,20 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
} else
view->colors = embedded_view_colors;
- /* Hack to prevent overflowing the visual map buffer.
- Yes, this does happen otherwise. */
+ // Hack to prevent overflowing the visual map buffer.
+ // Yes, this does happen otherwise.
if (view->index_yl + sci_titlebar_size > 200)
sci_titlebar_size = 0;
gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE);
if (flags & DRAWPIC01_FLAG_OVERLAID_PIC)
- view_transparentize(view, pic->visual_map->index_data,
- posx, sci_titlebar_size + posy,
+ view_transparentize(view, pic->visual_map->index_data, posx, sci_titlebar_size + posy,
view->index_xl, view->index_yl);
- _gfx_crossblit_simple(pic->visual_map->index_data + (sci_titlebar_size*320) +
- posy*320 + posx,
- view->index_data,
- pic->visual_map->index_xl, view->index_xl,
- view->index_xl,
- view->index_yl,
- 1);
+ _gfx_crossblit_simple(pic->visual_map->index_data + (sci_titlebar_size * 320) + posy * 320 + posx,
+ view->index_data, pic->visual_map->index_xl, view->index_xl,
+ view->index_xl, view->index_yl, 1);
gfx_free_mode(mode);
gfx_free_pixmap(NULL, view);
@@ -1882,8 +1762,8 @@ gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
case PIC_OP_TERMINATE:
p0printf("Terminator\n");
- /* warning( "ARTIFACT REMOVAL CODE is commented out!") */
- /* _gfxr_vismap_remove_artifacts(); */
+ //warning( "ARTIFACT REMOVAL CODE is commented out!")
+ //_gfxr_vismap_remove_artifacts();
return;
default:
@@ -1896,10 +1776,8 @@ end_op_loop: {}
GFXWARN("Reached end of pic resource %04x\n", resid);
}
-void
-gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size,
- byte *resource, gfxr_pic0_params_t *style, int resid,
- gfx_pixmap_color_t *static_pal, int static_pal_nr) {
+void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, byte *resource,
+ gfxr_pic0_params_t *style, int resid, gfx_pixmap_color_t *static_pal, int static_pal_nr) {
int has_bitmap = getUInt16(resource + 4);
int vector_data_ptr = getUInt16(resource + 16);
int palette_data_ptr = getUInt16(resource + 28);
@@ -1907,11 +1785,9 @@ gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size,
int sci_titlebar_size = style->pic_port_bounds.y;
gfx_mode_t *mode;
gfx_pixmap_t *view = NULL;
- /* Set up mode structure for resizing the view */
- mode = gfx_new_mode(
- pic->visual_map->index_xl / 320,
- pic->visual_map->index_yl / 200,
- 1, /* 1bpp, which handles masks and the rest for us */
+ // Set up mode structure for resizing the view
+ mode = gfx_new_mode(pic->visual_map->index_xl / 320, pic->visual_map->index_yl / 200,
+ 1, // 1bpp, which handles masks and the rest for us
0, 0, 0, 0, 0, 0, 0, 0, 16, 0);
pic->visual_map->colors = gfxr_read_pal11(-1, &(pic->visual_map->colors_nr), resource + palette_data_ptr, 1284);
@@ -1926,12 +1802,10 @@ gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size,
gfx_xlate_pixmap(view, mode, GFX_XLATE_FILTER_NONE);
if (flags & DRAWPIC01_FLAG_OVERLAID_PIC)
- view_transparentize(view, pic->visual_map->index_data,
- 0, 0,
- view->index_xl, view->index_yl);
+ view_transparentize(view, pic->visual_map->index_data, 0, 0, view->index_xl, view->index_yl);
- /* Hack to prevent overflowing the visual map buffer.
- Yes, this does happen otherwise. */
+ // Hack to prevent overflowing the visual map buffer.
+ // Yes, this does happen otherwise.
if (view->index_yl + sci_titlebar_size > 200)
sci_titlebar_size = 0;
@@ -1945,15 +1819,11 @@ gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size,
GFXWARN("No view was contained in SCI1.1 pic resource");
}
-
-
- gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr,
- resource + vector_data_ptr, style, resid, 1,
+ gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, resource + vector_data_ptr, style, resid, 1,
static_pal, static_pal_nr);
}
-void
-gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {
+void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {
int xl = pic->visual_map->index_xl;
int yl = pic->visual_map->index_yl;
int xfrob_max = (pattern == GFXR_DITHER_PATTERN_1) ? 1 : pic->mode->xfact;
@@ -1964,9 +1834,9 @@ gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {
byte *data = pic->visual_map->index_data;
if (dmode == GFXR_DITHER_MODE_F256)
- return; /* Nothing to do */
+ return; // Nothing to do
- if (dmode == GFXR_DITHER_MODE_D16) { /* Limit to 16 colors */
+ if (dmode == GFXR_DITHER_MODE_D16) { // Limit to 16 colors
pic->visual_map->colors = gfx_sci0_image_colors[sci0_palette];
pic->visual_map->colors_nr = GFX_SCI0_IMAGE_COLORS_NR;
}
@@ -1975,7 +1845,6 @@ gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {
for (x = 0; x < xl; x++) {
switch (dmode) {
-
case GFXR_DITHER_MODE_D16:
if (selection)
*data = (*data & 0xf0) >> 4;