diff options
author | Greg Frieger | 2009-03-03 14:27:49 +0000 |
---|---|---|
committer | Greg Frieger | 2009-03-03 14:27:49 +0000 |
commit | cbb6f919676bd1a44d91bf672487f11973094e97 (patch) | |
tree | 885db6744ae722cf256e5048b5d660ce2dba9d05 /engines | |
parent | eb610d66bdff66a6a768ab9fc7409a17959b17ab (diff) | |
download | scummvm-rg350-cbb6f919676bd1a44d91bf672487f11973094e97.tar.gz scummvm-rg350-cbb6f919676bd1a44d91bf672487f11973094e97.tar.bz2 scummvm-rg350-cbb6f919676bd1a44d91bf672487f11973094e97.zip |
SCI1: Improved color mapping when drawing line/box/text. Text with transparent background now displays correctly.
svn-id: r39089
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sci/engine/game.cpp | 3 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 17 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.cpp | 2 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 62 |
4 files changed, 41 insertions, 43 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index 16534dc910..f7e927f5a9 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -121,7 +121,7 @@ static void _sci1_alloc_system_colors(EngineState *s) { int _reset_graphics_input(EngineState *s) { Resource *resource; int font_nr; - gfx_color_t transparent; + gfx_color_t transparent = { { -1, 0, 0, 0 }, 0, -1, -1, 0 }; sciprintf("Initializing graphics\n"); if (s->resmgr->_sciVersion <= SCI_VERSION_01) { @@ -157,7 +157,6 @@ int _reset_graphics_input(EngineState *s) { } } } - transparent.mask = 0; gfxop_fill_box(s->gfx_state, gfx_rect(0, 0, 320, 200), s->ega_colors[0]); // Fill screen black gfxop_update(s->gfx_state); diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 2107b88ac7..847a030b2a 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -3081,11 +3081,11 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { reg_t textp = argv[0]; int index = UKPV_OR_ALT(1, 0); int temp; - int save_under = 0; - gfx_color_t transparent = { { 0, 0, 0, 0 }, 0, 0, 0, 0 }; + bool save_under = false; + gfx_color_t transparent = { { -1, 0, 0, 0 }, 0, -1, -1, 0 }; char *text; gfxw_port_t *port = (s->port) ? s->port : s->picture_port; - int update_immediately = 1; + bool update_immediately = true; gfx_color_t color0, *color1, bg_color; gfx_alignment_t halign = ALIGN_LEFT; @@ -3096,6 +3096,11 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { color0 = port->color; bg_color = port->bgcolor; + // TODO: in SCI1VGA the default colors for text and background are #0 (black) + // SCI0 case should be checked + if (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) { + color0.visual = bg_color.visual = *get_pic_color(s, 0); + } if (textp.segment) { argpt = 1; @@ -3184,7 +3189,7 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { case K_DISPLAY_SAVE_UNDER: - save_under = 1; + save_under = true; SCIkdebug(SCIkGRAPHICS, "Display: set_save_under()\n"); break; @@ -3192,13 +3197,13 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { SCIkdebug(SCIkGRAPHICS, "Display: restore_under(%04x)\n", UKPV(argpt)); graph_restore_box(s, argv[argpt++]); - update_immediately = 1; + update_immediately = true; argpt++; return s->r_acc; case K_DONT_UPDATE_IMMEDIATELY: - update_immediately = 0; + update_immediately = false; SCIkdebug(SCIkGRAPHICS, "Display: set_dont_update()\n"); argpt++; break; diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index 13dba23c36..6e74e1ebdf 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -2041,7 +2041,7 @@ gfxw_dyn_view_t *gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview) { gfxw_port_t *gfxw_get_chrono_port(gfxw_visual_t *visual, gfxw_list_t **temp_widgets_list, int flags) { gfxw_port_t *result = NULL; - gfx_color_t transparent = {{0, 0, 0, 0}, 0, 0, 0, 0}; + gfx_color_t transparent = {{-1, 0, 0, 01}, 0, -1, -1, 0}; int id = 0; if (!(flags & GFXW_CHRONO_NON_TOPMOST)) { diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 61e25ff393..f54ed539f5 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -662,6 +662,16 @@ int gfxop_set_color(gfx_state_t *state, gfx_color_t *color, int r, int g, int b, return GFX_OK; } +// Wrapper for gfxop_set_color +int gfxop_set_color(gfx_state_t *state, gfx_color_t *colorOut, gfx_color_t &colorIn) { + if (colorIn.mask & GFX_MASK_VISUAL) + return gfxop_set_color(state, colorOut, colorIn.visual.r, colorIn.visual.g, colorIn.visual.b, + colorIn.alpha, colorIn.priority, colorIn.control); + else + return gfxop_set_color(state, colorOut, -1, -1, -1, colorIn.alpha, + colorIn.priority, colorIn.control); +} + int gfxop_set_system_color(gfx_state_t *state, gfx_color_t *color) { gfx_palette_color_t *palette_colors; BASIC_CHECKS(GFX_FATAL); @@ -937,7 +947,9 @@ int gfxop_draw_line(gfx_state_t *state, Common::Point start, Common::Point end, end.x += xfact >> 1; end.y += yfact >> 1; } - + + if (color.visual.global_index == GFX_COLOR_INDEX_UNMAPPED) + gfxop_set_color(state, &color, color); return _gfxop_draw_line_clipped(state, start, end, color, line_mode, line_style); } @@ -1073,7 +1085,8 @@ int gfxop_draw_box(gfx_state_t *state, rect_t box, gfx_color_t color1, gfx_color // Reverse offset if we have to interpret colors inversely if (shade_type == GFX_BOX_SHADE_FLAT) { - gfxop_set_color(state, &color1, color1.visual.r, color1.visual.g, color1.visual.b, 0, 0, 0); + if (color1.visual.global_index == GFX_COLOR_INDEX_UNMAPPED) + gfxop_set_color(state, &color1, color1); return drv->draw_filled_rect(drv, new_box, color1, color1, GFX_SHADE_FLAT); } else { if (PALETTE_MODE) { @@ -1766,33 +1779,22 @@ int gfxop_get_text_params(gfx_state_t *state, int font_nr, const char *text, int return GFX_OK; } -#define COL_XLATE(des,src) \ - des = src.visual; /* The new gfx_color_t structure makes things a lot easier :-) */ /* \ - if (gfxop_set_color(state, &src, \ - src.visual.r, \ - src.visual.g, \ - src.visual.b, \ - src.alpha, \ - src.priority, \ - src.control)) \ - { \ - GFXERROR("Unable to set up colors"); \ - return NULL; \ - } -*/ - gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, int maxwidth, gfx_alignment_t halign, gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, gfx_color_t bg_color, int flags) { gfx_text_handle_t *handle; gfx_bitmap_font_t *font; - int i; - gfx_pixmap_color_t pxm_col1, pxm_col2, pxm_colbg; + int i, error = 0; BASIC_CHECKS(NULL); - COL_XLATE(pxm_col1, color1); - COL_XLATE(pxm_col2, color2); - COL_XLATE(pxm_colbg, bg_color); - + // mapping text colors to palette + error |= gfxop_set_color(state, &color1, color1); + error |= gfxop_set_color(state, &color2, color2); + error |= gfxop_set_color(state, &bg_color, bg_color); + if (error) { + GFXERROR("Unable to set up colors"); + return NULL; + } + font = gfxr_get_font(state->resstate, font_nr, 0); if (!font) { @@ -1830,9 +1832,9 @@ gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, i int chars_nr = handle->lines[i].length; handle->text_pixmaps[i] = gfxr_draw_font(font, handle->lines[i].offset, chars_nr, - (color1.mask & GFX_MASK_VISUAL) ? &pxm_col1 : NULL, - (color2.mask & GFX_MASK_VISUAL) ? &pxm_col2 : NULL, - (bg_color.mask & GFX_MASK_VISUAL) ? &pxm_colbg : NULL); + (color1.mask & GFX_MASK_VISUAL) ? &color1.visual : NULL, + (color2.mask & GFX_MASK_VISUAL) ? &color2.visual : NULL, + (bg_color.mask & GFX_MASK_VISUAL) ? &bg_color.visual : NULL); if (!handle->text_pixmaps[i]) { int j; @@ -1921,14 +1923,6 @@ int gfxop_draw_text(gfx_state_t *state, gfx_text_handle_t *handle, rect_t zone) gfx_pixmap_t *pxm = handle->text_pixmaps[i]; if (!pxm->data) { - // Matching pixmap's colors to current system palette if needed - gfx_color_t matched; - for (int j = 0; j < pxm->colors_nr; j++) { - gfxop_set_color(state, &matched, pxm->colors[j].r, pxm->colors[j].g, pxm->colors[j].b, - 0, 0, 0); - pxm->colors[j].global_index = matched.visual.global_index; - } - gfx_xlate_pixmap(pxm, state->driver->mode, state->options->text_xlate_filter); gfxr_endianness_adjust(pxm, state->driver->mode); // FIXME: resmgr layer! } |