diff options
author | Max Horn | 2009-02-26 16:16:53 +0000 |
---|---|---|
committer | Max Horn | 2009-02-26 16:16:53 +0000 |
commit | 3343dca6dc9dfe18d4f5e5a280c1e9ffe50da3d3 (patch) | |
tree | 9b432909b43e06dcbbca515608d0d77b0545c0ad /engines/sci | |
parent | fde001ce8148caef9a3c6480cc870a1f0727ed6a (diff) | |
download | scummvm-rg350-3343dca6dc9dfe18d4f5e5a280c1e9ffe50da3d3.tar.gz scummvm-rg350-3343dca6dc9dfe18d4f5e5a280c1e9ffe50da3d3.tar.bz2 scummvm-rg350-3343dca6dc9dfe18d4f5e5a280c1e9ffe50da3d3.zip |
SCI: Modified gfx_new_mode to take a Graphics::PixelFormat
svn-id: r38909
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/gfx/gfx_driver.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.cpp | 28 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.h | 16 | ||||
-rw-r--r-- | engines/sci/gfx/resource/sci_pic_0.cpp | 8 |
4 files changed, 27 insertions, 31 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index e77be19611..5951ef252f 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -44,8 +44,7 @@ struct _scummvm_driver_state { int _modifierStates; -static int -scummvm_init_specific(gfx_driver_t *drv, int xfact, int yfact, int bytespp) { +static int scummvm_init_specific(gfx_driver_t *drv, int xfact, int yfact, int bytespp) { int i; if (!drv->state) // = S @@ -77,7 +76,8 @@ scummvm_init_specific(gfx_driver_t *drv, int xfact, int yfact, int bytespp) { memset(S->visual[i], 0, S->xsize * S->ysize); } - drv->mode = gfx_new_mode(xfact, yfact, bytespp, 0, 0, 0, 0, 0, 0, 0, 0, 256, 0); + Graphics::PixelFormat format = { bytespp, 0, 0, 0, 0, 0, 0, 0, 0 }; + drv->mode = gfx_new_mode(xfact, yfact, format, 256, 0); return GFX_OK; } diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index fe3e99b6a8..db6fa7f834 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -44,22 +44,26 @@ void gfx_clip_box_basic(rect_t *box, int maxx, int maxy) { box->yl = maxy - box->y + 1; } -gfx_mode_t *gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask, - unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift, - int blue_shift, int alpha_shift, int palette, int flags) { +gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, int palette, int flags) { gfx_mode_t *mode = (gfx_mode_t *)sci_malloc(sizeof(gfx_mode_t)); mode->xfact = xfact; mode->yfact = yfact; - mode->bytespp = bytespp; - mode->red_mask = red_mask; - mode->green_mask = green_mask; - mode->blue_mask = blue_mask; - mode->alpha_mask = alpha_mask; - mode->red_shift = red_shift; - mode->green_shift = green_shift; - mode->blue_shift = blue_shift; - mode->alpha_shift = alpha_shift; + mode->bytespp = format.bytesPerPixel; + + // FIXME: I am not sure whether the following assignments are quite right. + // The only code using these are the built-in scalers of the SCI engine. + // And those are pretty weird, so I am not sure I interpreted them correctly. + // They also seem somewhat inefficient and and should probably just be + // replaced resp. rewritten from scratch. + mode->red_mask = format.ARGBToColor(0, 0xFF, 0, 0); + mode->green_mask = format.ARGBToColor(0, 0, 0xFF, 0); + mode->blue_mask = format.ARGBToColor(0, 0, 0, 0xFF); + mode->alpha_mask = format.ARGBToColor(0xFF, 0, 0, 0); + mode->red_shift = format.rLoss; + mode->green_shift = format.gLoss; + mode->blue_shift = format.bLoss; + mode->alpha_shift = format.aLoss; mode->flags = flags; if (palette) { diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h index bdd834f895..97451196e1 100644 --- a/engines/sci/gfx/gfx_tools.h +++ b/engines/sci/gfx/gfx_tools.h @@ -29,6 +29,8 @@ #ifndef SCI_GFX_GFX_TOOLS_H #define SCI_GFX_GFX_TOOLS_H +#include "graphics/pixelformat.h" + #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_driver.h" @@ -45,20 +47,10 @@ extern int gfx_crossblit_alpha_threshold; /* Crossblitting functions use this va ** for distinguishing between transparent and opaque ** wrt alpha values */ -gfx_mode_t *gfx_new_mode(int xfact, int yfact, int bytespp, unsigned int red_mask, unsigned int green_mask, - unsigned int blue_mask, unsigned int alpha_mask, int red_shift, int green_shift, - int blue_shift, int alpha_shift, int palette, int flags); +gfx_mode_t *gfx_new_mode(int xfact, int yfact, const Graphics::PixelFormat &format, int palette, int flags); /* Allocates a new gfx_mode_t structure with the specified parameters ** Parameters: (int x int) xfact x yfact: Horizontal and vertical scaling factors -** (int) bytespp: Bytes per pixel -** (unsigned int) red_mask: Red bit mask -** (unsigned int) green_mask: Green bit mask -** (unsigned int) blue_mask: Blue bit mask -** (unsigned int) Alpha_mask: Alpha bit mask, or 0 if the alpha channel is not supported -** (int) red_shift: Red shift value -** (int) green_shift: Green shift value -** (int) blue_shift: Blue shift value -** (int) alpha_shift: Alpha shift value +** (Graphics::PixelFormat) format: pixel format description ** (int) palette: Number of palette colors, 0 if we're not in palette mode ** (int) flags: GFX_MODE_FLAG_* values ORred together, or just 0 ** Returns : (gfx_mode_t *) A newly allocated gfx_mode_t structure diff --git a/engines/sci/gfx/resource/sci_pic_0.cpp b/engines/sci/gfx/resource/sci_pic_0.cpp index 4e470a9435..c8209cd172 100644 --- a/engines/sci/gfx/resource/sci_pic_0.cpp +++ b/engines/sci/gfx/resource/sci_pic_0.cpp @@ -1647,9 +1647,9 @@ void 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 + Graphics::PixelFormat format = { 1, 0, 0, 0, 0, 0, 0, 0, 0 }; // 1bpp, which handles masks and the rest for us 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->index_yl / 200, format, 16, 0); GET_ABS_COORDS(posx, posy); bytesize = (*(resource + pos)) + (*(resource + pos + 1) << 8); @@ -1779,9 +1779,9 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, gfx_mode_t *mode; gfx_pixmap_t *view = NULL; // Set up mode structure for resizing the view + Graphics::PixelFormat format = { 1, 0, 0, 0, 0, 0, 0, 0, 0 }; // 1bpp, which handles masks and the rest for us 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); + format, 16, 0); pic->visual_map->colors = gfxr_read_pal11(-1, &(pic->visual_map->colors_nr), resource + palette_data_ptr, 1284); |