- Re-added the SCI0 dithering code. Dithering is disabled by default. Added the 3 dithering modes as an enum (and reorganized them a bit)

- Added 3 config options for dithering in the ini file - mainly for purists (config option "dither_mode"): 0 - disabled, 1 - 16 color dithering (Sierra style) and 2 - 256 color dithering
- Dithering is now always applied depending on the screen scale (removed the relevant parameter)
- Removed the background picture buffering option, used to speed-up room changes. Room changing is quite fast (instantaneous), and the extra memory allocated is not worth the possible speed increase in small devices. Plus.... there is no reliable value to set this option to, so there is no point in letting the user decide what value to put there using guesswork

svn-id: r43915
This commit is contained in:
Filippos Karapetis 2009-09-03 07:01:48 +00:00
parent 3dca56bdd5
commit 557aaab0e6
5 changed files with 21 additions and 62 deletions

View File

@ -47,15 +47,9 @@ namespace Sci {
*/
struct gfx_options_t {
#ifdef CUSTOM_GRAPHICS_OPTIONS
int buffer_pics_nr; /* Number of unused pics to buffer in LRU storage */
/* SCI0 pic resource options */
int pic0_unscaled; /* Don't draw scaled SCI0 pics */
#if 0
int pic0_dither_mode; /* Mode to use for pic0 dithering, defined in gfx_resource.h */
int pic0_dither_pattern; /* Pattern to use for pic0 dithering, defined in gfx_resource.h */
#endif
DitherMode pic0_dither_mode; /* Mode to use for pic0 dithering, defined in gfx_resource.h */
gfx_brush_mode_t pic0_brush_mode;
gfx_line_mode_t pic0_line_mode;

View File

@ -119,12 +119,10 @@ int GfxResManager::calculatePic(gfxr_pic_t *scaled_pic, gfxr_pic_t *unscaled_pic
memcpy(scaled_pic->undithered_buffer, scaled_pic->visual_map->index_data, scaled_pic->undithered_buffer_size);
#if 0
#ifdef CUSTOM_GRAPHICS_OPTIONS
gfxr_dither_pic0(scaled_pic, _options->pic0_dither_mode, _options->pic0_dither_pattern);
gfxr_dither_pic0(scaled_pic, _options->pic0_dither_mode);
#else
gfxr_dither_pic0(scaled_pic, GFXR_DITHER_MODE_D256, GFXR_DITHER_PATTERN_SCALED);
#endif
gfxr_dither_pic0(scaled_pic, kDitherNone);
#endif
}
@ -152,21 +150,14 @@ int GfxResManager::getOptionsHash(gfx_resource_type_t type) {
return 10;
else
return (_options->pic0_unscaled) ? 0x10000 :
#if 0
(_options->pic0_dither_mode << 12) |
(_options->pic0_dither_pattern << 8) |
#endif
(_options->pic0_brush_mode << 4) |
(_options->pic0_line_mode);
#else
if (_resMan->isVGA())
return 10;
else
#if 0
return 0x10000 | (GFXR_DITHER_PATTERN_SCALED << 8) | (GFX_BRUSH_MODE_RANDOM_ELLIPSES << 4) | GFX_LINE_MODE_CORRECT;
#else
return 0x10000 | (GFX_BRUSH_MODE_RANDOM_ELLIPSES << 4) | GFX_LINE_MODE_CORRECT;
#endif
#endif
case GFX_RESOURCE_TYPE_FONT:
@ -384,11 +375,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale
if (!res) {
res = (gfx_resource_t *)malloc(sizeof(gfx_resource_t));
res->ID = GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, num);
#ifdef CUSTOM_GRAPHICS_OPTIONS
res->lock_sequence_nr = _options->buffer_pics_nr;
#else
res->lock_sequence_nr = 0;
#endif
resMap[num] = res;
} else {
gfxr_free_pic(res->scaled_data.pic);
@ -400,11 +387,7 @@ gfxr_pic_t *GfxResManager::getPic(int num, int maps, int flags, int default_pale
res->scaled_data.pic = pic;
res->unscaled_data.pic = unscaled_pic;
} else {
#ifdef CUSTOM_GRAPHICS_OPTIONS
res->lock_sequence_nr = _options->buffer_pics_nr; // Update lock counter
#else
res->lock_sequence_nr = 0;
#endif
}
#ifdef CUSTOM_GRAPHICS_OPTIONS
@ -496,11 +479,7 @@ gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_d
_gfxr_unscale_pixmap_index_data(res->scaled_data.pic->priority_map, _driver->getMode());
// The following two operations are needed when returning scaled maps (which is always the case here)
#ifdef CUSTOM_GRAPHICS_OPTIONS
res->lock_sequence_nr = _options->buffer_pics_nr;
#else
res->lock_sequence_nr = 0;
#endif
calculatePic(res->scaled_data.pic, need_unscaled ? res->unscaled_data.pic : NULL,
flags | DRAWPIC01_FLAG_OVERLAID_PIC, default_palette, new_nr);

View File

@ -42,17 +42,12 @@ namespace Common {
namespace Sci {
/*** Styles for pic0 drawing ***/
// These are used for the now-disabled dithering code. Is it even used anywhere?
#if 0
/* Dithering modes */
#define GFXR_DITHER_MODE_D16 0 /* Sierra SCI style */
#define GFXR_DITHER_MODE_F256 1 /* Flat color interpolation */
#define GFXR_DITHER_MODE_D256 2 /* 256 color dithering */
/* Dithering patterns */
#define GFXR_DITHER_PATTERN_SCALED 0 /* Dither per pixel on the 320x200 grid */
#define GFXR_DITHER_PATTERN_1 1 /* Dither per pixel on the target */
#endif
/* Dithering modes for SCI0 games */
enum DitherMode {
kDitherNone = 0, // No dithering
kDither16Colors = 1, // Sierra SCI style
kDither256Colors = 2 // Enhanced style
};
#define SCI_TITLEBAR_SIZE 10
@ -247,16 +242,13 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int fill_normally,
*/
void gfxr_remove_artifacts_pic0(gfxr_pic_t *dest, gfxr_pic_t *src);
#if 0
/**
* Dithers a gfxr_visual_map.
*
* @param[in] pic The pic to dither
* @param[in] mode One of GFXR_DITHER_MODE
* @param[in] pattern One of GFXR_DITHER_PATTERN
* @param[in] pic The pic to dither
* @param[DitherMode] mode The dithering mode to use
*/
void gfxr_dither_pic0(gfxr_pic_t *pic, int mode, int pattern);
#endif
void gfxr_dither_pic0(gfxr_pic_t *pic, DitherMode mode);
/**
* Calculates an EGA view.

View File

@ -1684,36 +1684,34 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size,
gfxr_draw_pic01(pic, flags, default_palette, size - vector_data_ptr, resource + vector_data_ptr, style, resid, kViewVga11, static_pal, portBounds);
}
#if 0
void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {
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 = (pattern == GFXR_DITHER_PATTERN_1) ? 1 : pic->mode->xfact;
int yfrob_max = (pattern == GFXR_DITHER_PATTERN_1) ? 1 : pic->mode->yfact;
int xfrob_max = pic->mode->xfact;
int yfrob_max = pic->mode->yfact;
int xfrobc = 0, yfrobc = 0;
int selection = 0;
int x, y;
byte *data = pic->visual_map->index_data;
if (dmode == GFXR_DITHER_MODE_F256)
if (dmode == kDitherNone)
return; // Nothing to do
if (dmode == GFXR_DITHER_MODE_D16) { // Limit to 16 colors
if (dmode == kDither16Colors)
pic->visual_map->palette = gfx_sci0_image_pal[sci0_palette]->getref();
}
for (y = 0; y < yl; y++) {
for (x = 0; x < xl; x++) {
switch (dmode) {
case GFXR_DITHER_MODE_D16:
case kDither16Colors:
if (selection)
*data = (*data & 0xf0) >> 4;
else
*data = (*data & 0xf);
break;
case GFXR_DITHER_MODE_D256:
case kDither256Colors:
if (selection)
*data = ((*data & 0xf) << 4) | ((*data & 0xf0) >> 4);
break;
@ -1737,6 +1735,5 @@ void gfxr_dither_pic0(gfxr_pic_t *pic, int dmode, int pattern) {
}
}
}
#endif
} // End of namespace Sci

View File

@ -164,17 +164,14 @@ Common::Error SciEngine::run() {
ConfMan.registerDefault("view_filter", "0");
ConfMan.registerDefault("pic_filter", "0");
ConfMan.registerDefault("text_filter", "0");
ConfMan.registerDefault("dither_mode", "0");
// Default config:
gfx_options_t gfx_options;
#ifdef CUSTOM_GRAPHICS_OPTIONS
gfx_options.buffer_pics_nr = 0;
gfx_options.pic0_unscaled = 1;
#if 0
gfx_options.pic0_dither_mode = GFXR_DITHER_MODE_F256;
gfx_options.pic0_dither_pattern = GFXR_DITHER_PATTERN_SCALED;
#endif
gfx_options.pic0_dither_mode = (DitherMode)ConfMan.getInt("dither_mode");
gfx_options.pic0_brush_mode = GFX_BRUSH_MODE_RANDOM_ELLIPSES;
gfx_options.pic0_line_mode = GFX_LINE_MODE_CORRECT;
gfx_options.cursor_xlate_filter = (gfx_xlate_filter_t)ConfMan.getInt("cursor_filter");