diff options
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r-- | engines/sci/gfx/gfx_driver.cpp | 15 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_pixmap_scale.cpp | 23 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 18 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_support.cpp | 4 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_system.h | 7 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.cpp | 13 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 64 | ||||
-rw-r--r-- | engines/sci/gfx/picfill.cpp | 8 | ||||
-rw-r--r-- | engines/sci/gfx/res_pic.cpp | 119 |
9 files changed, 129 insertions, 142 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index e71081ce2c..91c5fadc23 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -83,22 +83,21 @@ static void drawProc(int x, int y, int c, void *data) { GfxDriver *drv = (GfxDriver *)data; byte *p = drv->getVisual0(); uint8 col = c; - memcpy(p + (y * 320* drv->getMode()->xfact + x), &col, 1); + memcpy(p + (y * 320* drv->getMode()->scaleFactor + x), &col, 1); } void GfxDriver::drawLine(Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { uint32 scolor = color.visual.parent_index; - int xfact = (line_mode == GFX_LINE_MODE_FINE)? 1: _mode->xfact; - int yfact = (line_mode == GFX_LINE_MODE_FINE)? 1: _mode->yfact; + int scaleFactor = (line_mode == GFX_LINE_MODE_FINE)? 1: _mode->scaleFactor; int xsize = _mode->xsize; int ysize = _mode->ysize; if (color.mask & GFX_MASK_VISUAL) { Common::Point nstart, nend; - for (int xc = 0; xc < xfact; xc++) { - for (int yc = 0; yc < yfact; yc++) { + for (int xc = 0; xc < scaleFactor; xc++) { + for (int yc = 0; yc < scaleFactor; yc++) { nstart.x = CLIP<int16>(start.x + xc, 0, xsize); nstart.y = CLIP<int16>(start.y + yc, 0, ysize); @@ -229,14 +228,14 @@ byte *GfxDriver::createCursor(gfx_pixmap_t *pointer) { // Note that some cursors don't have a palette in SQ5 if (pointer->palette && color < pointer->palette->size()) color = pointer->palette->getColor(color).parent_index; - for (int scalectr = 0; scalectr < _mode->xfact; scalectr++) { + for (int scalectr = 0; scalectr < _mode->scaleFactor; scalectr++) { *pos++ = color; } src++; } - for (int scalectr = 1; scalectr < _mode->yfact; scalectr++) + for (int scalectr = 1; scalectr < _mode->scaleFactor; scalectr++) memcpy(linebase + linewidth * scalectr, linebase, linewidth); - linebase += linewidth * _mode->yfact; + linebase += linewidth * _mode->scaleFactor; } return data; } diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index 9e4578a813..65a44c524f 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -40,10 +40,9 @@ namespace Sci { static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, int scale) { byte result_colors[GFX_PIC_COLORS]; - int xfact = (scale) ? mode->xfact : 1; - int yfact = (scale) ? mode->yfact : 1; + int scaleFactor = (scale) ? mode->scaleFactor : 1; int widthc, heightc; // Width duplication counter - int line_width = xfact * pxm->index_width; + int line_width = scaleFactor * pxm->index_width; int x, y; int i; byte byte_transparent = 0; @@ -55,7 +54,7 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in int separate_alpha_map = using_alpha; if (separate_alpha_map && !alpha_dest) - alpha_dest = pxm->alpha_map = (byte *)malloc(pxm->index_width * xfact * pxm->index_height * yfact); + alpha_dest = pxm->alpha_map = (byte *)malloc(pxm->index_width * scaleFactor * pxm->index_height * scaleFactor); // Calculate all colors for (i = 0; i < pxm->colors_nr(); i++) @@ -77,20 +76,20 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in // O(n) loops. There is an O(ln(n)) algorithm for this, but its slower for small n (which we're optimizing for here). // And, anyway, most of the time is spent in memcpy() anyway. - for (widthc = 0; widthc < xfact; widthc++) { + for (widthc = 0; widthc < scaleFactor; widthc++) { memcpy(dest, &col, 1); dest++; } if (separate_alpha_map) { // Set separate alpha map - memset(alpha_dest, (isalpha) ? byte_transparent : byte_opaque, xfact); - alpha_dest += xfact; + memset(alpha_dest, (isalpha) ? byte_transparent : byte_opaque, scaleFactor); + alpha_dest += scaleFactor; } } // Copies each line. O(n) iterations; again, this could be optimized to O(ln(n)) for very high resolutions, // but that wouldn't really help that much, as the same amount of data still would have to be transferred. - for (heightc = 1; heightc < yfact; heightc++) { + for (heightc = 1; heightc < scaleFactor; heightc++) { memcpy(dest, prev_dest, line_width); dest += line_width; if (separate_alpha_map) { @@ -104,8 +103,8 @@ static void _gfx_xlate_pixmap_unfiltered(gfx_mode_t *mode, gfx_pixmap_t *pxm, in pxm->width = pxm->index_width; pxm->height = pxm->index_height; } else { - pxm->width = pxm->index_width * mode->xfact; - pxm->height = pxm->index_height * mode->yfact; + pxm->width = pxm->index_width * mode->scaleFactor; + pxm->height = pxm->index_height * mode->scaleFactor; } } @@ -115,13 +114,13 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { pxm->palette->mergeInto(mode->palette); if (!pxm->data) { - pxm->data = (byte*)malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height + 1); + pxm->data = (byte*)malloc(mode->scaleFactor * mode->scaleFactor * pxm->index_width * pxm->index_height + 1); // +1: Eases coying on BE machines in 24 bpp packed mode // Assume that memory, if allocated already, will be sufficient // Allocate alpha map if (pxm->colors_nr() < GFX_PIC_COLORS) - pxm->alpha_map = (byte*)malloc(mode->xfact * mode->yfact * pxm->index_width * pxm->index_height + 1); + pxm->alpha_map = (byte*)malloc(mode->scaleFactor * mode->scaleFactor * pxm->index_width * pxm->index_height + 1); } _gfx_xlate_pixmap_unfiltered(mode, pxm, !(pxm->flags & GFX_PIXMAP_FLAG_SCALED_INDEX)); diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 17b5b4e3ed..9e064c3d8f 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -312,11 +312,9 @@ static gfxr_pic_t *gfxr_pic_xlate_common(gfx_resource_t *res, int maps, int scal */ // FIXME: this is an ugly hack. Perhaps we could do it some other way? gfx_mode_t mode_1x1_color_index = { /* Fake 1x1 mode */ - /* xfact */ 1, /* yfact */ 1, + /* scaleFactor */ 1, /* xsize */ 1, /* ysize */ 1, - /* palette */ NULL, - - Graphics::PixelFormat() + /* palette */ NULL }; gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_palette, bool scaled) { @@ -324,7 +322,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_PIC]; gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_PIC); - int need_unscaled = (_driver->getMode()->xfact != 1 || _driver->getMode()->yfact != 1); + int need_unscaled = (_driver->getMode()->scaleFactor != 1); hash |= (flags << 20) | ((default_palette & 0x7) << 28); @@ -417,8 +415,8 @@ static int get_pic_id(gfx_resource_t *res) { } static void _gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) { - int xmod = mode->xfact; // Step size horizontally - int ymod = pxm->index_width * mode->yfact; // Vertical step size + int xmod = mode->scaleFactor; // Step size horizontally + int ymod = pxm->index_width * mode->scaleFactor; // Vertical step size int maxpos = pxm->index_width * pxm->index_height; int pos; byte *dest = pxm->index_data; @@ -435,8 +433,8 @@ static void _gfxr_unscale_pixmap_index_data(gfx_pixmap_t *pxm, gfx_mode_t *mode) // and left to the reader) } - pxm->index_width /= mode->xfact; - pxm->index_height /= mode->yfact; + pxm->index_width /= mode->scaleFactor; + pxm->index_height /= mode->scaleFactor; pxm->flags &= ~GFX_PIXMAP_FLAG_SCALED_INDEX; } @@ -446,7 +444,7 @@ gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_d gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_PIC); #ifdef CUSTOM_GRAPHICS_OPTIONS - int need_unscaled = !(_options->pic0_unscaled) && (_driver->getMode()->xfact != 1 || _driver->getMode()->yfact != 1); + int need_unscaled = !(_options->pic0_unscaled) && (_driver->getMode()->scaleFactor != 1 || _driver->getMode()->scaleFactor != 1); #else int need_unscaled = 1; #endif diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 1f48a6d2ab..fa3b94835a 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -177,8 +177,8 @@ void _gfx_crossblit_simple(byte *dest, byte *src, int dest_line_width, int src_l void 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) { - int maxx = 320 * mode->xfact; - int maxy = 200 * mode->yfact; + int maxx = 320 * mode->scaleFactor; + int maxy = 200 * mode->scaleFactor; byte *src = pxm->data; byte *alpha = pxm->alpha_map ? pxm->alpha_map : pxm->data; byte *priority_pos = priority_dest; diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index 59d6006858..526b61d04f 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -30,7 +30,6 @@ #include "common/rect.h" #include "sci/tools.h" #include "sci/gfx/palette.h" -#include "graphics/pixelformat.h" namespace Sci { @@ -42,7 +41,7 @@ namespace Sci { #define GFX_COLOR_SYSTEM -1 -#define GFX_MODE_IS_UNSCALED(mode) (((mode)->xfact == 1) && ((mode)->yfact == 1)) +#define GFX_MODE_IS_UNSCALED(mode) (((mode)->scaleFactor == 1) && ((mode)->scaleFactor == 1)) /** Graphics mode description * @@ -59,15 +58,13 @@ namespace Sci { struct gfx_mode_t { - int xfact, yfact; /**< Horizontal and vertical scaling factors */ + int scaleFactor; /**< Horizontal and vertical scaling factor */ int xsize, ysize; /**< Horizontal and vertical size */ /** * Palette or NULL to indicate non-palette mode. */ Palette *palette; - - Graphics::PixelFormat format; }; diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 2a6550598e..34632260b3 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -46,9 +46,8 @@ void gfx_clip_box_basic(rect_t *box, int maxx, int maxy) { gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, Palette *palette, int flags) { gfx_mode_t *mode = (gfx_mode_t *)malloc(sizeof(gfx_mode_t)); - mode->xfact = xfact; - mode->yfact = yfact; - mode->format = format; + mode->scaleFactor = xfact; + mode->scaleFactor = yfact; mode->palette = palette; return mode; @@ -177,8 +176,8 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { pixmap->width = pixmap->index_width; pixmap->height = pixmap->index_height; } else { - pixmap->width = pixmap->index_width * mode->xfact; - pixmap->height = pixmap->index_height * mode->yfact; + pixmap->width = pixmap->index_width * mode->scaleFactor; + pixmap->height = pixmap->index_height * mode->scaleFactor; } size = pixmap->width * pixmap->height; @@ -207,8 +206,8 @@ gfx_pixmap_t *gfx_pixmap_scale_index_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode int linewidth; int xl, yl; int i, yc; - int xfact = mode->xfact; - int yfact = mode->yfact; + int xfact = mode->scaleFactor; + int yfact = mode->scaleFactor; if (xfact == 1 && yfact == 1) return pixmap; diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 992a33177e..0e655424a7 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -69,15 +69,15 @@ gfx_pixmap_color_t default_colors[DEFAULT_COLORS_NR] = {{GFX_COLOR_SYSTEM, 0x00, // Internal operations static void _gfxop_scale_rect(rect_t *rect, gfx_mode_t *mode) { - rect->x *= mode->xfact; - rect->y *= mode->yfact; - rect->width *= mode->xfact; - rect->height *= mode->yfact; + rect->x *= mode->scaleFactor; + rect->y *= mode->scaleFactor; + rect->width *= mode->scaleFactor; + rect->height *= mode->scaleFactor; } static void _gfxop_scale_point(Common::Point *point, gfx_mode_t *mode) { - point->x *= mode->xfact; - point->y *= mode->yfact; + point->x *= mode->scaleFactor; + point->y *= mode->scaleFactor; } int _gfxop_clip(rect_t *rect, rect_t clipzone) { @@ -117,13 +117,13 @@ int _gfxop_clip(rect_t *rect, rect_t clipzone) { static void _gfxop_grab_pixmap(GfxState *state, gfx_pixmap_t **pxmp, int x, int y, int xl, int yl, int priority, rect_t *zone) { // Returns 1 if the resulting data size was zero, GFX_OK or an error code otherwise */ - int xfact = state->driver->getMode()->xfact; - int yfact = state->driver->getMode()->yfact; + int xfact = state->driver->getMode()->scaleFactor; + int yfact = state->driver->getMode()->scaleFactor; int unscaled_xl = (xl + xfact - 1) / xfact; int unscaled_yl = (yl + yfact - 1) / yfact; *zone = gfx_rect(x, y, xl, yl); - if (_gfxop_clip(zone, gfx_rect(0, 0, 320 * state->driver->getMode()->xfact, 200 * state->driver->getMode()->yfact))) + if (_gfxop_clip(zone, gfx_rect(0, 0, 320 * state->driver->getMode()->scaleFactor, 200 * state->driver->getMode()->scaleFactor))) error("_gfxop_grab_pixmap: zone was empty"); if (!*pxmp) @@ -221,7 +221,7 @@ static void _gfxop_draw_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm, int priorit rect_t clipped_dest = gfx_rect(dest.x, dest.y, dest.width, dest.height); if (control >= 0 || priority >= 0) { - Common::Point original_pos = Common::Point(dest.x / driver->getMode()->xfact, dest.y / driver->getMode()->yfact); + Common::Point original_pos = Common::Point(dest.x / driver->getMode()->scaleFactor, dest.y / driver->getMode()->scaleFactor); if (control >= 0) _gfxop_draw_control(control_map, pxm, control, original_pos); @@ -242,8 +242,8 @@ static void _gfxop_draw_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm, int priorit _gfxop_install_pixmap(driver, pxm); - DDIRTY(stderr, "\\-> Drawing to actual %d %d %d %d\n", clipped_dest.x / driver->getMode()->xfact, - clipped_dest.y / driver->getMode()->yfact, clipped_dest.width / driver->getMode()->xfact, clipped_dest.height / driver->getMode()->yfact); + DDIRTY(stderr, "\\-> Drawing to actual %d %d %d %d\n", clipped_dest.x / driver->getMode()->scaleFactor, + clipped_dest.y / driver->getMode()->scaleFactor, clipped_dest.width / driver->getMode()->scaleFactor, clipped_dest.height / driver->getMode()->scaleFactor); driver->drawPixmap(pxm, priority, src, clipped_dest, static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); } @@ -252,8 +252,8 @@ static void _gfxop_full_pointer_refresh(GfxState *state) { bool clipped = false; Common::Point mousePoint = g_system->getEventManager()->getMousePos(); - state->pointer_pos.x = mousePoint.x / state->driver->getMode()->xfact; - state->pointer_pos.y = mousePoint.y / state->driver->getMode()->yfact; + state->pointer_pos.x = mousePoint.x / state->driver->getMode()->scaleFactor; + state->pointer_pos.y = mousePoint.y / state->driver->getMode()->scaleFactor; if (state->pointer_pos.x < state->pointerZone.left) { state->pointer_pos.x = state->pointerZone.left; @@ -273,8 +273,8 @@ static void _gfxop_full_pointer_refresh(GfxState *state) { // FIXME: Do this only when mouse is grabbed? if (clipped) - g_system->warpMouse(state->pointer_pos.x * state->driver->getMode()->xfact, - state->pointer_pos.y * state->driver->getMode()->yfact); + g_system->warpMouse(state->pointer_pos.x * state->driver->getMode()->scaleFactor, + state->pointer_pos.y * state->driver->getMode()->scaleFactor); } static void _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t buffer); @@ -489,8 +489,8 @@ void gfxop_set_clip_zone(GfxState *state, rect_t zone) { DDIRTY(stderr, "-- Setting clip zone %d %d %d %d\n", GFX_PRINT_RECT(zone)); - xfact = state->driver->getMode()->xfact; - yfact = state->driver->getMode()->yfact; + xfact = state->driver->getMode()->scaleFactor; + yfact = state->driver->getMode()->scaleFactor; if (zone.x < MIN_X) { zone.width -= (zone.x - MIN_X); @@ -665,7 +665,7 @@ static void simulate_stippled_line_draw(GfxDriver *driver, int skipone, Common:: // Draws a stippled line if this isn't supported by the driver (skipone is ignored ATM) int xl = end.x - start.x; int yl = end.y - start.y; - int stepwidth = (xl) ? driver->getMode()->xfact : driver->getMode()->yfact; + int stepwidth = (xl) ? driver->getMode()->scaleFactor : driver->getMode()->scaleFactor; int dbl_stepwidth = 2 * stepwidth; int linelength = (line_mode == GFX_LINE_MODE_FINE) ? stepwidth - 1 : 0; int16 *posvar; @@ -741,7 +741,7 @@ static void _gfxop_draw_line_clipped(GfxState *state, Common::Point start, Commo || start.y < state->clip_zone.y || end.x >= (state->clip_zone.x + state->clip_zone.width) || end.y >= (state->clip_zone.y + state->clip_zone.height)) - if (point_clip(&start, &end, state->clip_zone, state->driver->getMode()->xfact - 1, state->driver->getMode()->yfact - 1)) + if (point_clip(&start, &end, state->clip_zone, state->driver->getMode()->scaleFactor - 1, state->driver->getMode()->scaleFactor - 1)) return; // Clipped off if (line_style == GFX_LINE_STYLE_STIPPLED) { @@ -759,8 +759,8 @@ void gfxop_draw_line(GfxState *state, Common::Point start, Common::Point end, _gfxop_add_dirty_x(state, gfx_rect(start.x, start.y, end.x - start.x, end.y - start.y)); - xfact = state->driver->getMode()->xfact; - yfact = state->driver->getMode()->yfact; + xfact = state->driver->getMode()->scaleFactor; + yfact = state->driver->getMode()->scaleFactor; draw_line_to_control_map(state, start, end, color); @@ -788,8 +788,8 @@ void gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_l _gfxop_full_pointer_refresh(state); - xfact = state->driver->getMode()->xfact; - yfact = state->driver->getMode()->yfact; + xfact = state->driver->getMode()->scaleFactor; + yfact = state->driver->getMode()->scaleFactor; int offset = line_mode == GFX_LINE_MODE_FINE ? 1 : 0; x = rect.x * xfact + (xfact - 1) * offset; @@ -937,7 +937,7 @@ void gfxop_fill_box(GfxState *state, rect_t box, gfx_color_t color) { } static void _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t buffer) { - if (_gfxop_clip(&box, gfx_rect(0, 0, 320 * state->driver->getMode()->xfact, 200 * state->driver->getMode()->yfact))) + if (_gfxop_clip(&box, gfx_rect(0, 0, 320 * state->driver->getMode()->scaleFactor, 200 * state->driver->getMode()->scaleFactor))) return; state->driver->update(box, Common::Point(box.x, box.y), buffer); @@ -1113,7 +1113,7 @@ void gfxop_set_pointer_position(GfxState *state, Common::Point pos) { return; // Not fatal } - g_system->warpMouse(pos.x * state->driver->getMode()->xfact, pos.y * state->driver->getMode()->yfact); + g_system->warpMouse(pos.x * state->driver->getMode()->scaleFactor, pos.y * state->driver->getMode()->scaleFactor); // Trigger event reading to make sure the mouse coordinates will // actually have changed the next time we read them. @@ -1584,8 +1584,8 @@ static void _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, C old_x = pos.x -= pxm->xoffset; old_y = pos.y -= pxm->yoffset; - pos.x *= state->driver->getMode()->xfact; - pos.y *= state->driver->getMode()->yfact; + pos.x *= state->driver->getMode()->scaleFactor; + pos.y *= state->driver->getMode()->scaleFactor; if (!static_buf) _gfxop_add_dirty(state, gfx_rect(old_x, old_y, pxm->index_width, pxm->index_height)); @@ -1646,7 +1646,7 @@ void gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { state->palette_nr = default_palette; state->pic = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true); - if (state->driver->getMode()->xfact == 1 && state->driver->getMode()->yfact == 1) { + if (state->driver->getMode()->scaleFactor == 1 && state->driver->getMode()->scaleFactor == 1) { state->pic_unscaled = state->pic; } else { state->pic_unscaled = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, false); @@ -1830,7 +1830,7 @@ void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { _gfxop_scale_rect(&zone, state->driver->getMode()); - line_height = handle->line_height * state->driver->getMode()->yfact; + line_height = handle->line_height * state->driver->getMode()->scaleFactor; pos.y = zone.y; @@ -1914,8 +1914,8 @@ void gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common:: _gfxop_scale_rect(&zone, state->driver->getMode()); _gfxop_scale_rect(&target, state->driver->getMode()); - return _gfxop_draw_pixmap(state->driver, pxm, -1, -1, zone, target, gfx_rect(0, 0, 320*state->driver->getMode()->xfact, - 200*state->driver->getMode()->yfact), 0, NULL, NULL); + return _gfxop_draw_pixmap(state->driver, pxm, -1, -1, zone, target, gfx_rect(0, 0, 320*state->driver->getMode()->scaleFactor, + 200*state->driver->getMode()->scaleFactor), 0, NULL, NULL); } void gfxop_free_pixmap(GfxState *state, gfx_pixmap_t *pxm) { diff --git a/engines/sci/gfx/picfill.cpp b/engines/sci/gfx/picfill.cpp index 6b909c27af..f48f7e938d 100644 --- a/engines/sci/gfx/picfill.cpp +++ b/engines/sci/gfx/picfill.cpp @@ -229,9 +229,9 @@ static void AUXBUF_FILL(gfxr_pic_t *pic, int x, int y, int clipmask, int control static void FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, byte *bounds, int legalcolor, int legalmask, int color, int priority, int drawenable, int sci_titlebar_size) { - int linewidth = pic->mode->xfact * 320; - int miny = pic->mode->yfact * sci_titlebar_size; - int maxy = pic->mode->yfact * 200; + int linewidth = pic->mode->scaleFactor * 320; + int miny = pic->mode->scaleFactor * sci_titlebar_size; + int maxy = pic->mode->scaleFactor * 200; int xl, xr; int oldytotal = y * linewidth; #ifdef DRAW_SCALED @@ -432,7 +432,7 @@ static void FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int static void FILL_FUNCTION(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, int control, int drawenable, int sci_titlebar_size) { - int linewidth = pic->mode->xfact * 320; + int linewidth = pic->mode->scaleFactor * 320; int x, y; int xl, xr; int ytotal; diff --git a/engines/sci/gfx/res_pic.cpp b/engines/sci/gfx/res_pic.cpp index adf2bf1c2c..ce4510510a 100644 --- a/engines/sci/gfx/res_pic.cpp +++ b/engines/sci/gfx/res_pic.cpp @@ -150,12 +150,12 @@ gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, bool sci1) { pic->control_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320, 200, ID, 2, 0)); - pic->priority_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(mode->xfact * 320, mode->yfact * 200, + pic->priority_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(mode->scaleFactor * 320, mode->scaleFactor * 200, ID, 1, 0)); - pic->visual_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320 * mode->xfact, - 200 * mode->yfact, ID, 0, 0)); + pic->visual_map = gfx_pixmap_alloc_index_data(gfx_new_pixmap(320 * mode->scaleFactor, + 200 * mode->scaleFactor, ID, 0, 0)); // Initialize colors if (!sci1) { @@ -169,7 +169,7 @@ gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, bool sci1) { pic->visual_map->flags = 0; pic->priority_map->flags = 0; pic->control_map->flags = 0; - if (mode->xfact > 1 || mode->yfact > 1) { + if (mode->scaleFactor > 1) { pic->visual_map->flags |= GFX_PIXMAP_FLAG_SCALED_INDEX; pic->priority_map->flags |= GFX_PIXMAP_FLAG_SCALED_INDEX; } @@ -187,12 +187,12 @@ gfxr_pic_t *gfxr_init_pic(gfx_mode_t *mode, int ID, bool sci1) { // Pic rendering operations void gfxr_clear_pic0(gfxr_pic_t *pic, int titlebar_size) { - memset(pic->visual_map->index_data, 0x00, (320 * pic->mode->xfact * titlebar_size * pic->mode->yfact)); - memset(pic->visual_map->index_data + (320 * pic->mode->xfact * titlebar_size * pic->mode->yfact), - 0xff, pic->mode->xfact * 320 * pic->mode->yfact * (200 - titlebar_size)); // white - memset(pic->priority_map->index_data + (320 * pic->mode->xfact * titlebar_size * pic->mode->yfact), - 0x0, pic->mode->xfact * 320 * pic->mode->yfact * (200 - titlebar_size)); - memset(pic->priority_map->index_data, 0x0a, titlebar_size * (pic->mode->yfact * 320 * pic->mode->xfact)); + memset(pic->visual_map->index_data, 0x00, (320 * pic->mode->scaleFactor * titlebar_size * pic->mode->scaleFactor)); + memset(pic->visual_map->index_data + (320 * pic->mode->scaleFactor * titlebar_size * pic->mode->scaleFactor), + 0xff, pic->mode->scaleFactor * 320 * pic->mode->scaleFactor * (200 - titlebar_size)); // white + memset(pic->priority_map->index_data + (320 * pic->mode->scaleFactor * titlebar_size * pic->mode->scaleFactor), + 0x0, pic->mode->scaleFactor * 320 * pic->mode->scaleFactor * (200 - titlebar_size)); + memset(pic->priority_map->index_data, 0x0a, titlebar_size * (pic->mode->scaleFactor * 320 * pic->mode->scaleFactor)); memset(pic->control_map->index_data, 0, GFXR_AUX_MAP_SIZE); memset(pic->aux_map, 0, GFXR_AUX_MAP_SIZE); } @@ -465,8 +465,8 @@ static void _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int // 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; + int line_width = 320 * pic->mode->scaleFactor; + int full_offset = (yoffset * pic->mode->scaleFactor + offset) * pic->mode->scaleFactor; if (yoffset + offset >= 64000) { error("_gfxr_auxplot_brush() failed. Breakpoint in %s, line %d", __FILE__, __LINE__); @@ -475,27 +475,27 @@ static void _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int switch (brush_mode) { case GFX_BRUSH_MODE_SCALED: if (plot) - for (yc = 0; yc < pic->mode->yfact; yc++) { - memset(buffer + full_offset, color, pic->mode->xfact); + for (yc = 0; yc < pic->mode->scaleFactor; yc++) { + memset(buffer + full_offset, color, pic->mode->scaleFactor); full_offset += line_width; } break; 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); + int x = offset * pic->mode->scaleFactor + ((pic->mode->scaleFactor - 1) >> 1); + int y = (yoffset / 320) * pic->mode->scaleFactor + ((pic->mode->scaleFactor - 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->scaleFactor >> 1, pic->mode->scaleFactor >> 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); - int sizex = pic->mode->xfact >> 1; - int sizey = pic->mode->yfact >> 1; + int x = offset * pic->mode->scaleFactor + ((pic->mode->scaleFactor - 1) >> 1); + int y = (yoffset / 320) * pic->mode->scaleFactor + ((pic->mode->scaleFactor - 1) >> 1); + int sizex = pic->mode->scaleFactor >> 1; + int sizey = pic->mode->scaleFactor >> 1; srand(randseed); @@ -506,7 +506,7 @@ static void _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int sizex = (int)((sizex * rand() * 1.0) / (RAND_MAX + 1.0)); sizey = (int)((sizey * rand() * 1.0) / (RAND_MAX + 1.0)); - _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->xfact >> 1, pic->mode->yfact >> 1, + _gfxr_fill_ellipse(pic, buffer, line_width, x, y, pic->mode->scaleFactor >> 1, pic->mode->scaleFactor >> 1, color, ELLIPSE_SOLID); srand(time(NULL)); // Make sure we don't accidently forget to re-init the random number generator } @@ -515,8 +515,8 @@ static void _gfxr_auxplot_brush(gfxr_pic_t *pic, byte *buffer, int yoffset, int case GFX_BRUSH_MODE_MORERANDOM: { int mask = plot ? 7 : 1; srand(randseed); - for (yc = 0; yc < pic->mode->yfact; yc++) { - for (xc = 0; xc < pic->mode->xfact; xc++) + for (yc = 0; yc < pic->mode->scaleFactor; yc++) { + for (xc = 0; xc < pic->mode->scaleFactor; xc++) if ((rand() & 7) < mask) buffer[full_offset + xc] = color; full_offset += line_width; @@ -654,8 +654,8 @@ static void _gfxr_plot_aux_pattern(gfxr_pic_t *pic, int x, int y, int size, int 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 titlebar_size) { - int xsize = (pattern_size + 1) * pic->mode->xfact - 1; - int ysize = (pattern_size + 1) * pic->mode->yfact - 1; + int xsize = (pattern_size + 1) * pic->mode->scaleFactor - 1; + int ysize = (pattern_size + 1) * pic->mode->scaleFactor - 1; int scaled_x, scaled_y; rect_t boundaries; int max_x = (pattern_code & PATTERN_FLAG_RECTANGLE) ? 318 : 319; // Rectangles' width is size+1 @@ -676,20 +676,20 @@ static void _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int pri if (y + pattern_size > 199) y = 199 - pattern_size; - scaled_x = x * pic->mode->xfact + ((pic->mode->xfact - 1) >> 1); - scaled_y = y * pic->mode->yfact + ((pic->mode->yfact - 1) >> 1); + scaled_x = x * pic->mode->scaleFactor + ((pic->mode->scaleFactor - 1) >> 1); + scaled_y = y * pic->mode->scaleFactor + ((pic->mode->scaleFactor - 1) >> 1); if (scaled_x < xsize) scaled_x = xsize; - if (scaled_y < ysize + titlebar_size * pic->mode->yfact) - scaled_y = ysize + titlebar_size * pic->mode->yfact; + if (scaled_y < ysize + titlebar_size * pic->mode->scaleFactor) + scaled_y = ysize + titlebar_size * pic->mode->scaleFactor; - if (scaled_x > (320 * pic->mode->xfact) - 1 - xsize) - scaled_x = (320 * pic->mode->xfact) - 1 - xsize; + if (scaled_x > (320 * pic->mode->scaleFactor) - 1 - xsize) + scaled_x = (320 * pic->mode->scaleFactor) - 1 - xsize; - if (scaled_y > (200 * pic->mode->yfact) - 1 - ysize) - scaled_y = (200 * pic->mode->yfact) - 1 - ysize; + if (scaled_y > (200 * pic->mode->scaleFactor) - 1 - ysize) + scaled_y = (200 * pic->mode->scaleFactor) - 1 - ysize; if (pattern_code & PATTERN_FLAG_RECTANGLE) { // Rectangle @@ -723,7 +723,7 @@ static void _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int pri _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 (pic->mode->scaleFactor == 1 && pic->mode->scaleFactor == 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); @@ -733,11 +733,11 @@ static void _gfxr_draw_pattern(gfxr_pic_t *pic, int x, int y, int color, int pri 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, + _gfxr_fill_ellipse(pic, pic->visual_map->index_data, 320 * pic->mode->scaleFactor, 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, + _gfxr_fill_ellipse(pic, pic->priority_map->index_data, 320 * pic->mode->scaleFactor, scaled_x, scaled_y, xsize, ysize, priority, ELLIPSE_SOLID); } } @@ -769,8 +769,8 @@ static void _gfxr_draw_subline(gfxr_pic_t *pic, int x, int y, int ex, int ey, in 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 titlebar_size) { - int scale_x = pic->mode->xfact; - int scale_y = pic->mode->yfact; + int scale_x = pic->mode->scaleFactor; + int scale_y = pic->mode->scaleFactor; int xc, yc; rect_t line; int mask; @@ -886,12 +886,12 @@ static void _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int c #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++) { \ + mpos = (((yy) * 320 * pic->mode->scaleFactor) + (xx)) * pic->mode->scaleFactor; \ + for (iy = 0; iy < pic->mode->scaleFactor; iy++) { \ + for (ix = 0; ix < pic->mode->scaleFactor; ix++) { \ if (!IS_FILL_BOUNDARY(test_map[mpos + ix])) { \ - *x = ix + (xx) * pic->mode->xfact; \ - *y = iy + (yy) * pic->mode->yfact; \ + *x = ix + (xx) * pic->mode->scaleFactor; \ + *y = iy + (yy) * pic->mode->scaleFactor; \ return 0; \ } \ mpos += linewidth; \ @@ -902,7 +902,7 @@ static void _gfxr_draw_line(gfxr_pic_t *pic, int x, int y, int ex, int ey, int c static 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 linewidth = pic->mode->scaleFactor * 320; int mpos, ix, iy; int size_x = (max_x - min_x + 1) >> 1; int size_y = (max_y - min_y + 1) >> 1; @@ -913,8 +913,8 @@ static int _gfxr_find_fill_point(gfxr_pic_t *pic, int min_x, int min_y, int max_ int legalcolor; int legalmask; byte *test_map; - *x = x_320 * pic->mode->xfact; - *y = y_200 * pic->mode->yfact; + *x = x_320 * pic->mode->scaleFactor; + *y = y_200 * pic->mode->scaleFactor; if (size_x < 0 || size_y < 0) return 0; @@ -1063,35 +1063,32 @@ static void check_and_remove_artifact(byte *dest, byte* srcp, int legalcolor, by 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; - int scaled_line_size = bound_x * 320; + int scaled_line_size = dest->mode->scaleFactor * 320; int read_offset = 0; - assert(src->mode->xfact == 1); - assert(src->mode->yfact == 1); + assert(src->mode->scaleFactor == 1); - if (bound_x == 1 && bound_y == 1) { + if (dest->mode->scaleFactor == 1) { warning("[GFX] attempt to remove artifacts from unscaled pic"); return; } for (y_200 = 0; y_200 < 200; y_200++) { for (x_320 = 0; x_320 < 320; x_320++) { - int write_offset = (y_200 * bound_y * scaled_line_size) + (x_320 * bound_x); + int write_offset = (y_200 * dest->mode->scaleFactor * scaled_line_size) + (x_320 * dest->mode->scaleFactor); int sub_x, sub_y; byte *src_visualp = &(src->visual_map->index_data[read_offset]); byte *src_priorityp = &(src->priority_map->index_data[read_offset]); - for (sub_y = 0; sub_y < bound_y; sub_y++) { - for (sub_x = 0; sub_x < bound_x; sub_x++) { + for (sub_y = 0; sub_y < dest->mode->scaleFactor; sub_y++) { + for (sub_x = 0; sub_x < dest->mode->scaleFactor; sub_x++) { 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, (byte)x_320, (byte)(x_320 < 319), (byte)(y_200 > 10), (byte)(y_200 < 199)); ++write_offset; } - write_offset += scaled_line_size - bound_x; + write_offset += scaled_line_size - dest->mode->scaleFactor; } ++read_offset; } @@ -1290,7 +1287,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, debugC(2, kDebugLevelSci0Pic, "Abs coords %d,%d\n", x, y); //fprintf(stderr,"C=(%d,%d)\n", x, y + titlebar_size); #ifdef WITH_PIC_SCALING - if (pic->mode->xfact > 1 || pic->mode->yfact > 1) + if (pic->mode->scaleFactor > 1) _gfxr_fill_any(pic, x, y + titlebar_size, (flags & DRAWPIC01_FLAG_FILL_NORMALLY) ? color : 0, priority, control, drawenable, titlebar_size); @@ -1627,8 +1624,6 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, void gfxr_dither_pic0(gfxr_pic_t *pic, DitherMode dmode) { int xl = pic->visual_map->index_width; int yl = pic->visual_map->index_height; - int xfrob_max = pic->mode->xfact; - int yfrob_max = pic->mode->yfact; int xfrobc = 0, yfrobc = 0; int selection = 0; int x, y; @@ -1663,13 +1658,13 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, DitherMode dmode) { ++data; - if (++xfrobc == xfrob_max) { + if (++xfrobc == pic->mode->scaleFactor) { selection = !selection; xfrobc = 0; } } - if (++yfrobc == yfrob_max) { + if (++yfrobc == pic->mode->scaleFactor) { selection = !selection; yfrobc = 0; } |