diff options
author | Filippos Karapetis | 2009-10-28 13:20:30 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-10-28 13:20:30 +0000 |
commit | 04ab6bc9fc831702a26c229027dada1436509b83 (patch) | |
tree | 4b0ba4fe63ef9d7b0a1d868d4cec97c53dba397b /engines/sci/gfx | |
parent | f28fe1b07423941c245e06376761054507d188c1 (diff) | |
download | scummvm-rg350-04ab6bc9fc831702a26c229027dada1436509b83.tar.gz scummvm-rg350-04ab6bc9fc831702a26c229027dada1436509b83.tar.bz2 scummvm-rg350-04ab6bc9fc831702a26c229027dada1436509b83.zip |
Enclose all of the old graphics code within the INCLUDE_OLDGFX safeguard (defined in sci.h)
svn-id: r45459
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r-- | engines/sci/gfx/gfx_driver.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_driver.h | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_gui.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_gui.h | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_pixmap_scale.cpp | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resmgr.h | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resource.cpp | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_resource.h | 15 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_state_internal.h | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_support.cpp | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_system.h | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.cpp | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_tools.h | 5 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.cpp | 6 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.h | 4 | ||||
-rw-r--r-- | engines/sci/gfx/menubar.cpp | 11 | ||||
-rw-r--r-- | engines/sci/gfx/menubar.h | 6 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 673 | ||||
-rw-r--r-- | engines/sci/gfx/operations.h | 65 | ||||
-rw-r--r-- | engines/sci/gfx/palette.cpp | 5 | ||||
-rw-r--r-- | engines/sci/gfx/palette.h | 5 |
22 files changed, 486 insertions, 372 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index 1ab8381022..41205a0ecc 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -23,13 +23,15 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "common/scummsys.h" #include "common/system.h" #include "graphics/cursorman.h" #include "graphics/primitives.h" #include "graphics/surface.h" -#include "sci/sci.h" #include "sci/gui/gui_screen.h" #include "sci/gfx/gfx_driver.h" #include "sci/gfx/gfx_tools.h" @@ -199,3 +201,5 @@ void GfxDriver::animatePalette(int fromColor, int toColor, int stepCount) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h index 5fb6b35ef3..f0809a6ba1 100644 --- a/engines/sci/gfx/gfx_driver.h +++ b/engines/sci/gfx/gfx_driver.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_DRIVER_H #define SCI_GFX_GFX_DRIVER_H @@ -222,3 +225,5 @@ private: } // End of namespace Sci #endif // SCI_GFX_GFX_DRIVER_H + +#endif diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp index fa4106d613..2cfe0f3a39 100644 --- a/engines/sci/gfx/gfx_gui.cpp +++ b/engines/sci/gfx/gfx_gui.cpp @@ -23,7 +23,9 @@ * */ -#include "sci/sci.h" +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/engine/state.h" #include "sci/gfx/operations.h" #include "sci/gfx/gfx_widgets.h" @@ -660,3 +662,5 @@ void _k_view_list_mark_free(EngineState *s, reg_t off) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_gui.h b/engines/sci/gfx/gfx_gui.h index c8cb8650b0..be724ae873 100644 --- a/engines/sci/gfx/gfx_gui.h +++ b/engines/sci/gfx/gfx_gui.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_INCLUDE_SCI_WIDGETS_H #define SCI_INCLUDE_SCI_WIDGETS_H @@ -218,3 +221,5 @@ GfxPort *sciw_toggle_item(GfxPort *menu_port, Menu *menu, int selection, } // End of namespace Sci #endif // SCI_INCLUDE_SCI_WIDGETS_H + +#endif diff --git a/engines/sci/gfx/gfx_pixmap_scale.cpp b/engines/sci/gfx/gfx_pixmap_scale.cpp index 5b126f71d2..d542683cee 100644 --- a/engines/sci/gfx/gfx_pixmap_scale.cpp +++ b/engines/sci/gfx/gfx_pixmap_scale.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + /* Required defines: ** FUNCNAME: Function name ** SIZETYPE: Type used for each pixel @@ -126,3 +129,5 @@ void gfx_xlate_pixmap(gfx_pixmap_t *pxm, gfx_mode_t *mode) { } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index 27858aa1b6..f78f5980e9 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -23,13 +23,15 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + // Resource manager core part // FIXME/TODO: The name "(Graphics) resource manager", and the associated // filenames, are misleading. This should be renamed to "Graphics manager" // or something like that. -#include "sci/sci.h" #include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_resmgr.h" @@ -526,3 +528,5 @@ gfx_bitmap_font_t *GfxResManager::getFont(int num, bool scaled) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_resmgr.h b/engines/sci/gfx/gfx_resmgr.h index 17598b0b53..5b3b728702 100644 --- a/engines/sci/gfx/gfx_resmgr.h +++ b/engines/sci/gfx/gfx_resmgr.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_RESMAN_H #define SCI_GFX_GFX_RESMAN_H @@ -282,3 +285,5 @@ private: } // End of namespace Sci #endif // SCI_GFX_GFX_RESMAN_H + +#endif diff --git a/engines/sci/gfx/gfx_resource.cpp b/engines/sci/gfx/gfx_resource.cpp index 4eae7942c5..fe2373e4e2 100644 --- a/engines/sci/gfx/gfx_resource.cpp +++ b/engines/sci/gfx/gfx_resource.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_tools.h" @@ -73,3 +76,5 @@ void gfxr_free_pic(gfxr_pic_t *pic) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h index 56fb16295a..d3f1c727a5 100644 --- a/engines/sci/gfx/gfx_resource.h +++ b/engines/sci/gfx/gfx_resource.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + /** @file gfx_resource.h * SCI Resource library. */ @@ -32,6 +35,7 @@ #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_driver.h" +#include "sci/gui/gui_helpers.h" #include "common/rect.h" @@ -75,15 +79,6 @@ extern PaletteEntry gfx_sci0_image_colors[][16]; */ extern Palette* gfx_sci0_pic_colors; - -enum ViewType { - kViewUnknown, - kViewEga, - kViewVga, - kViewVga11, - kViewAmiga -}; - struct gfxr_pic0_params_t { gfx_line_mode_t line_mode; /* one of GFX_LINE_MODE_* */ gfx_brush_mode_t brush_mode; @@ -290,3 +285,5 @@ gfx_pixmap_t *gfxr_draw_cel1(int id, int loop, int cel, int mirrored, byte *reso } // End of namespace Sci #endif // SCI_GFX_GFX_RESOURCE_H + +#endif diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h index 5334971e23..ec8219dc46 100644 --- a/engines/sci/gfx/gfx_state_internal.h +++ b/engines/sci/gfx/gfx_state_internal.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_STATE_INTERNAL_H #define SCI_GFX_GFX_STATE_INTERNAL_H @@ -410,3 +413,5 @@ public: } // End of namespace Sci #endif // SCI_GFX_GFX_STATE_INTERNAL_H + +#endif diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index 867e555907..8efe59b855 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + /* Graphics support functions for drivers and replacements for driver functions ** for use with the graphical state manager */ @@ -274,3 +277,5 @@ void gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, rec } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_system.h b/engines/sci/gfx/gfx_system.h index 31b799b8fe..d57c68552e 100644 --- a/engines/sci/gfx/gfx_system.h +++ b/engines/sci/gfx/gfx_system.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_SYSTEM #define SCI_GFX_GFX_SYSTEM @@ -279,3 +282,5 @@ struct gfx_color_t { } // End of namespace Sci #endif // SCI_GFX_GFX_SYSTEM + +#endif diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index eef89ded1b..0ea488fe1d 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/gfx_tools.h" namespace Sci { @@ -156,3 +159,5 @@ gfx_pixmap_t *gfx_pixmap_alloc_data(gfx_pixmap_t *pixmap, gfx_mode_t *mode) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h index 2d15b51022..06543532e8 100644 --- a/engines/sci/gfx/gfx_tools.h +++ b/engines/sci/gfx/gfx_tools.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_GFX_TOOLS_H #define SCI_GFX_GFX_TOOLS_H @@ -184,3 +187,5 @@ void gfx_crossblit_pixmap(gfx_mode_t *mode, gfx_pixmap_t *pxm, int priority, } // End of namespace Sci #endif // SCI_GFX_GFX_TOOLS_H + +#endif diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index f667381fdc..d260e66cfc 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -23,7 +23,9 @@ * */ -#include "sci/sci.h" +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/gfx_gui.h" // for kWindowAutoRestore #include "sci/gfx/gfx_widgets.h" #include "sci/gfx/gfx_state_internal.h" @@ -1769,3 +1771,5 @@ GfxDynView *gfxw_picviewize_dynview(GfxDynView *dynview) { } } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/gfx_widgets.h b/engines/sci/gfx/gfx_widgets.h index 6369eabd19..d30af8ce4e 100644 --- a/engines/sci/gfx/gfx_widgets.h +++ b/engines/sci/gfx/gfx_widgets.h @@ -23,6 +23,8 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX #ifndef SCI_GFX_GFX_WIDGETS_H #define SCI_GFX_GFX_WIDGETS_H @@ -471,3 +473,5 @@ void gfxw_port_auto_restore_background(GfxVisual *visual, GfxPort *window, } // End of namespace Sci #endif // SCI_GFX_GFX_WIDGETS_H + +#endif diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp index 62120097ab..cf3c3a7414 100644 --- a/engines/sci/gfx/menubar.cpp +++ b/engines/sci/gfx/menubar.cpp @@ -77,6 +77,7 @@ MenuItem::MenuItem() { _tag = 0; } +#ifdef INCLUDE_OLDGFX int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const char *right, int font, int key, int modifiers, int tag, reg_t text_pos) { @@ -107,14 +108,18 @@ int Menu::addMenuItem(GfxState *state, MenuType type, const char *left, const ch } if (right) { +#ifdef INCLUDE_OLDGFX gfxop_get_text_params(state, font, item->_keytext.c_str(), SIZE_INF, &width, &height, 0, NULL, NULL, NULL); +#endif total_left_size = MENU_BOX_CENTER_PADDING + width; } item->_enabled = 1; item->_tag = tag; item->_textPos = text_pos; +#ifdef INCLUDE_OLDGFX gfxop_get_text_params(state, font, left, SIZE_INF, &width, &height, 0, NULL, NULL, NULL); +#endif _items.push_back(newItem); @@ -133,7 +138,9 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common menu._title = title; +#ifdef INCLUDE_OLDGFX gfxop_get_text_params(state, font, title.c_str(), SIZE_INF, &(menu._titleWidth), &height, 0, NULL, NULL, NULL); +#endif const char *entries_p = entries.c_str(); @@ -169,7 +176,9 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common beginning = entries_base; beginning.offset -= string_len + 1; +#ifdef INCLUDE_OLDGFX c_width = menu.addMenuItem(state, entrytype, left, NULL, font, 0, 0, tag, beginning); +#endif if (c_width > max_width) max_width = c_width; @@ -269,6 +278,8 @@ void Menubar::addMenu(GfxState *state, const Common::String &title, const Common _menus.push_back(menu); } +#endif + bool MenuItem::matchKey(int message, int modifiers) { if ((_key == message) && ((modifiers & (SCI_EVM_CTRL | SCI_EVM_ALT)) == _modifiers)) return true; diff --git a/engines/sci/gfx/menubar.h b/engines/sci/gfx/menubar.h index 5a440a480b..4c7281a36d 100644 --- a/engines/sci/gfx/menubar.h +++ b/engines/sci/gfx/menubar.h @@ -28,6 +28,7 @@ #ifndef SCI_GFX_SCI_MENUBAR_H #define SCI_GFX_SCI_MENUBAR_H +#include "sci/sci.h" // for INCLUDE_OLDGFX #include "sci/engine/vm_types.h" #include "sci/gfx/operations.h" @@ -138,8 +139,10 @@ public: //protected: // FIXME: This should be (partially) turned into a MenuItem constructor +#ifdef INCLUDE_OLDGFX int addMenuItem(GfxState *state, MenuType type, const char *left, const char *right, int font, int key, int modifiers, int tag, reg_t text_pos); +#endif }; @@ -171,8 +174,9 @@ public: * @param[in] font The font which is to be used for drawing * @param[in] entries_base Segmented VM address of the entries string */ +#ifdef INCLUDE_OLDGFX void addMenu(GfxState *state, const Common::String &title, const Common::String &entries, int font, reg_t entries_base); - +#endif /** * Sets the attributes for a menu item. diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index a89968598b..d50341887d 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -27,7 +27,9 @@ #include "sci/sci.h" #include "sci/gfx/operations.h" +#ifdef INCLUDE_OLDGFX #include "sci/gui32/font.h" +#endif #include "sci/console.h" #include "common/system.h" @@ -35,6 +37,8 @@ namespace Sci { +#ifdef INCLUDE_OLDGFX + #define PRECISE_PRIORITY_MAP // Duplicate all operations on the local priority map as appropriate #undef GFXW_DEBUG_DIRTY @@ -871,6 +875,341 @@ void gfxop_disable_dirty_frames(GfxState *state) { state->disable_dirty = 1; } +// View operations + +void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { + gfxr_view_t *view = NULL; + gfx_pixmap_t *pxm = NULL; + + view = state->gfxResMan->getView(nr, &loop, &cel, 0); + + if (!view) + error("[GFX] Attempt to get cel parameters for invalid view %d", nr); + + pxm = view->loops[loop].cels[cel]; + *width = pxm->index_width; + *height = pxm->index_height; + offset->x = pxm->xoffset; + offset->y = pxm->yoffset; +} + +static void _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int static_buf, int palette) { + int priority = (color.mask & GFX_MASK_PRIORITY) ? color.priority : -1; + int control = (color.mask & GFX_MASK_CONTROL) ? color.control : -1; + gfxr_view_t *view = NULL; + gfx_pixmap_t *pxm = NULL; + int old_x, old_y; + + view = state->gfxResMan->getView(nr, &loop, &cel, palette); + + if (!view) { + warning("[GFX] Attempt to draw loop/cel %d/%d in invalid view %d\n", loop, cel, nr); + return; + } + pxm = view->loops[loop].cels[cel]; + + old_x = pos.x -= pxm->xoffset; + old_y = pos.y -= pxm->yoffset; + + 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)); + + _gfxop_draw_pixmap(state->driver, pxm, priority, control, gfx_rect(0, 0, pxm->width, pxm->height), + gfx_rect(pos.x, pos.y, pxm->width, pxm->height), state->clip_zone, static_buf , state->control_map, + static_buf ? state->static_priority_map : state->priority_map); +} + +void gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { + _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 0, palette); +} + +void gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { + rect_t oldclip = state->clip_zone; + + state->clip_zone = gfx_rect_fullscreen; + _gfxop_scale_rect(&(state->clip_zone), state->driver->getMode()); + gfxop_draw_cel_static_clipped(state, nr, loop, cel, pos, color, palette); + // Except that the area it's clipped against is... unusual ;-) + state->clip_zone = oldclip; +} + +void gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { + _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 1, palette); +} + +// Pic operations + +static void _gfxop_set_pic(GfxState *state) { + gfx_copy_pixmap_box_i(state->control_map, state->pic->control_map, gfx_rect(0, 0, 320, 200)); + gfx_copy_pixmap_box_i(state->priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); + gfx_copy_pixmap_box_i(state->static_priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); + + // Reset global palette to this PIC's palette + // FIXME: The _gfxop_install_pixmap call below updates the OSystem palette. + // This is too soon, since it causes brief palette corruption until the + // screen is updated too. (Possibly related: EngineState::pic_not_valid .) + if (state->pic->visual_map->palette) { + state->pic->visual_map->palette->forceInto(SCREEN_PALETTE); + _gfxop_install_pixmap(state->driver, state->pic->visual_map); + } + + state->driver->setStaticBuffer(state->pic->visual_map, state->pic->priority_map); +} + +void gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { + state->gfxResMan->tagResources(); + state->tag_mode = 1; + state->palette_nr = default_palette; + state->pic = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true); + + 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); + } + + if (!state->pic || !state->pic_unscaled) { + warning("Could not retrieve background pic %d", nr); + if (state->pic) { + warning(" -- Inconsistency: scaled pic _was_ retrieved!"); + } + + if (state->pic_unscaled) { + warning(" -- Inconsistency: unscaled pic _was_ retrieved!"); + } + + error("Error occured in gfxop_new_pic()"); + state->pic = state->pic_unscaled = NULL; + } + + state->pic_nr = nr; + + _gfxop_set_pic(state); +} + +void gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) { + if (!state->pic) + error("Attempt to add to pic with no pic active"); + + state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); + + if (!state->pic) + error("Could not add pic #%d to pic #%d", state->pic_nr, nr); + + state->pic_unscaled = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); + + _gfxop_set_pic(state); +} + +// Text operations + +void gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int maxwidth, int *width, int *height, int text_flags, + int *lines_nr, int *lineheight, int *lastline_width) { + Common::Array<TextFragment> fragments; + bool textsplits; + gfx_bitmap_font_t *font; + + font = state->gfxResMan->getFont(font_nr); + + if (!font) + error("Attempt to calculate text size with invalid font #%d", font_nr); + + textsplits = gfxr_font_calculate_size(fragments, font, maxwidth, text, width, height, lineheight, lastline_width, text_flags); + + if (!textsplits) + error("Could not calculate text size"); + + if (lines_nr) + *lines_nr = fragments.size(); +} + +TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &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) { + TextHandle *handle; + gfx_bitmap_font_t *font; + + // mapping text colors to palette + gfxop_set_color(state, &color1, color1); + gfxop_set_color(state, &color2, color2); + gfxop_set_color(state, &bg_color, bg_color); + + font = state->gfxResMan->getFont(font_nr); + + if (!font) { + error("Attempt to draw text with invalid font #%d", font_nr); + return NULL; + } + + handle = new TextHandle(); + + handle->_text = text; + handle->halign = halign; + handle->valign = valign; + handle->line_height = font->line_height; + + bool result = gfxr_font_calculate_size(handle->lines, font, maxwidth, handle->_text.c_str(), &(handle->width), &(handle->height), + NULL, NULL, flags); + + if (!result) { + error("Could not calculate text parameters in font #%d", font_nr); + delete handle; + return NULL; + } + + if (flags & kFontNoNewlines) { + handle->lines.resize(1); + handle->lines[0].length = text.size(); + } + + handle->text_pixmaps.resize(handle->lines.size()); + + for (uint i = 0; i < handle->lines.size(); 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) ? &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]) { + error("Failed to draw text pixmap for line %d/%d", i, handle->lines.size()); + delete handle; + return NULL; + } + } + + handle->font = font; + + handle->priority = (color1.mask & GFX_MASK_PRIORITY) ? color1.priority : -1; + handle->control = (color1.mask & GFX_MASK_CONTROL) ? color1.control : -1; + + return handle; +} + +TextHandle::TextHandle() { + line_height = 0; + font = 0; + + width = height = 0; + + priority = control = 0; + halign = valign = ALIGN_BOTTOM; +} + +TextHandle::~TextHandle() { + for (uint j = 0; j < text_pixmaps.size(); j++) + if (text_pixmaps[j]) + gfx_free_pixmap(text_pixmaps[j]); +} + +void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { + int line_height; + rect_t pos; + + if (!handle) + error("Attempt to draw text with NULL handle"); + + if (handle->lines.empty()) { + debugC(2, kDebugLevelGraphics, "Skipping draw_text operation because number of lines is zero\n"); + return; + } + + _gfxop_scale_rect(&zone, state->driver->getMode()); + + line_height = handle->line_height * state->driver->getMode()->scaleFactor; + + pos.y = zone.y; + + switch (handle->valign) { + + case ALIGN_TOP: + break; + + case ALIGN_CENTER: + pos.y += (zone.height - (line_height * handle->lines.size())) >> 1; + break; + + case ALIGN_BOTTOM: + pos.y += (zone.height - (line_height * handle->lines.size())); + break; + + default: + error("Invalid vertical alignment %d", handle->valign); + } + + for (uint i = 0; i < handle->lines.size(); i++) { + + gfx_pixmap_t *pxm = handle->text_pixmaps[i]; + + if (!pxm->data) { + gfx_xlate_pixmap(pxm, state->driver->getMode()); + } + if (!pxm) + error("Could not find text pixmap %d/%d", i, handle->lines.size()); + + pos.x = zone.x; + + switch (handle->halign) { + + case ALIGN_LEFT: + break; + + case ALIGN_CENTER: + pos.x += (zone.width - pxm->width) >> 1; + break; + + case ALIGN_RIGHT: + pos.x += (zone.width - pxm->width); + break; + + default: + error("Invalid vertical alignment %d", handle->valign); + } + + pos.width = pxm->width; + pos.height = pxm->height; + + _gfxop_add_dirty(state, pos); + _gfxop_draw_pixmap(state->driver, pxm, handle->priority, handle->control, + gfx_rect(0, 0, pxm->width, pxm->height), pos, state->clip_zone, 0, state->control_map, state->priority_map); + + pos.y += line_height; + } +} + +gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { + gfx_pixmap_t *pixmap = NULL; + rect_t resultzone; // Ignored for this application + + _gfxop_scale_rect(&area, state->driver->getMode()); + _gfxop_grab_pixmap(state, &pixmap, area.x, area.y, area.width, area.height, 0, &resultzone); + + return pixmap; +} + +void gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos) { + rect_t target = gfx_rect(pos.x, pos.y, zone.width, zone.height); + + if (!pxm) + error("Attempt to draw NULL pixmap"); + + _gfxop_add_dirty(state, target); + + _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()->scaleFactor, + 200*state->driver->getMode()->scaleFactor), 0, NULL, NULL); +} + + + +#endif // INCLUDE_OLDGFX + + // Pointer and IO ops void gfxop_sleep(GfxState *state, uint32 msecs) { @@ -1003,7 +1342,7 @@ static int _gfxop_numlockify(int c) { } } -static sci_event_t scummvm_get_event(GfxDriver *drv) { +static sci_event_t scummvm_get_event() { static int _modifierStates = 0; // FIXME: Avoid non-const global vars sci_event_t input = { SCI_EVT_NONE, 0, 0, 0 }; @@ -1216,7 +1555,7 @@ sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) { // Get all queued events from graphics driver do { - event = scummvm_get_event(state->driver); + event = scummvm_get_event(); if (event.type != SCI_EVT_NONE) state->_events.push_back(event); } while (event.type != SCI_EVT_NONE); @@ -1263,334 +1602,4 @@ sci_event_t gfxop_get_event(GfxState *state, unsigned int mask) { return event; } -// View operations - -void gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *width, int *height, Common::Point *offset) { - gfxr_view_t *view = NULL; - gfx_pixmap_t *pxm = NULL; - - view = state->gfxResMan->getView(nr, &loop, &cel, 0); - - if (!view) - error("[GFX] Attempt to get cel parameters for invalid view %d", nr); - - pxm = view->loops[loop].cels[cel]; - *width = pxm->index_width; - *height = pxm->index_height; - offset->x = pxm->xoffset; - offset->y = pxm->yoffset; -} - -static void _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int static_buf, int palette) { - int priority = (color.mask & GFX_MASK_PRIORITY) ? color.priority : -1; - int control = (color.mask & GFX_MASK_CONTROL) ? color.control : -1; - gfxr_view_t *view = NULL; - gfx_pixmap_t *pxm = NULL; - int old_x, old_y; - - view = state->gfxResMan->getView(nr, &loop, &cel, palette); - - if (!view) { - warning("[GFX] Attempt to draw loop/cel %d/%d in invalid view %d\n", loop, cel, nr); - return; - } - pxm = view->loops[loop].cels[cel]; - - old_x = pos.x -= pxm->xoffset; - old_y = pos.y -= pxm->yoffset; - - 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)); - - _gfxop_draw_pixmap(state->driver, pxm, priority, control, gfx_rect(0, 0, pxm->width, pxm->height), - gfx_rect(pos.x, pos.y, pxm->width, pxm->height), state->clip_zone, static_buf , state->control_map, - static_buf ? state->static_priority_map : state->priority_map); -} - -void gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 0, palette); -} - -void gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - rect_t oldclip = state->clip_zone; - - state->clip_zone = gfx_rect_fullscreen; - _gfxop_scale_rect(&(state->clip_zone), state->driver->getMode()); - gfxop_draw_cel_static_clipped(state, nr, loop, cel, pos, color, palette); - // Except that the area it's clipped against is... unusual ;-) - state->clip_zone = oldclip; -} - -void gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 1, palette); -} - -// Pic operations - -static void _gfxop_set_pic(GfxState *state) { - gfx_copy_pixmap_box_i(state->control_map, state->pic->control_map, gfx_rect(0, 0, 320, 200)); - gfx_copy_pixmap_box_i(state->priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); - gfx_copy_pixmap_box_i(state->static_priority_map, state->pic_unscaled->priority_map, gfx_rect(0, 0, 320, 200)); - - // Reset global palette to this PIC's palette - // FIXME: The _gfxop_install_pixmap call below updates the OSystem palette. - // This is too soon, since it causes brief palette corruption until the - // screen is updated too. (Possibly related: EngineState::pic_not_valid .) - if (state->pic->visual_map->palette) { - state->pic->visual_map->palette->forceInto(SCREEN_PALETTE); - _gfxop_install_pixmap(state->driver, state->pic->visual_map); - } - - state->driver->setStaticBuffer(state->pic->visual_map, state->pic->priority_map); -} - -void gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { - state->gfxResMan->tagResources(); - state->tag_mode = 1; - state->palette_nr = default_palette; - state->pic = state->gfxResMan->getPic(nr, GFX_MASK_VISUAL, flags, default_palette, true); - - 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); - } - - if (!state->pic || !state->pic_unscaled) { - warning("Could not retrieve background pic %d", nr); - if (state->pic) { - warning(" -- Inconsistency: scaled pic _was_ retrieved!"); - } - - if (state->pic_unscaled) { - warning(" -- Inconsistency: unscaled pic _was_ retrieved!"); - } - - error("Error occured in gfxop_new_pic()"); - state->pic = state->pic_unscaled = NULL; - } - - state->pic_nr = nr; - - _gfxop_set_pic(state); -} - -void gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) { - if (!state->pic) - error("Attempt to add to pic with no pic active"); - - state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); - - if (!state->pic) - error("Could not add pic #%d to pic #%d", state->pic_nr, nr); - - state->pic_unscaled = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); - - _gfxop_set_pic(state); -} - -// Text operations - -void gfxop_get_text_params(GfxState *state, int font_nr, const char *text, int maxwidth, int *width, int *height, int text_flags, - int *lines_nr, int *lineheight, int *lastline_width) { - Common::Array<TextFragment> fragments; - bool textsplits; - gfx_bitmap_font_t *font; - - font = state->gfxResMan->getFont(font_nr); - - if (!font) - error("Attempt to calculate text size with invalid font #%d", font_nr); - - textsplits = gfxr_font_calculate_size(fragments, font, maxwidth, text, width, height, lineheight, lastline_width, text_flags); - - if (!textsplits) - error("Could not calculate text size"); - - if (lines_nr) - *lines_nr = fragments.size(); -} - -TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &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) { - TextHandle *handle; - gfx_bitmap_font_t *font; - - // mapping text colors to palette - gfxop_set_color(state, &color1, color1); - gfxop_set_color(state, &color2, color2); - gfxop_set_color(state, &bg_color, bg_color); - - font = state->gfxResMan->getFont(font_nr); - - if (!font) { - error("Attempt to draw text with invalid font #%d", font_nr); - return NULL; - } - - handle = new TextHandle(); - - handle->_text = text; - handle->halign = halign; - handle->valign = valign; - handle->line_height = font->line_height; - - bool result = gfxr_font_calculate_size(handle->lines, font, maxwidth, handle->_text.c_str(), &(handle->width), &(handle->height), - NULL, NULL, flags); - - if (!result) { - error("Could not calculate text parameters in font #%d", font_nr); - delete handle; - return NULL; - } - - if (flags & kFontNoNewlines) { - handle->lines.resize(1); - handle->lines[0].length = text.size(); - } - - handle->text_pixmaps.resize(handle->lines.size()); - - for (uint i = 0; i < handle->lines.size(); 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) ? &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]) { - error("Failed to draw text pixmap for line %d/%d", i, handle->lines.size()); - delete handle; - return NULL; - } - } - - handle->font = font; - - handle->priority = (color1.mask & GFX_MASK_PRIORITY) ? color1.priority : -1; - handle->control = (color1.mask & GFX_MASK_CONTROL) ? color1.control : -1; - - return handle; -} - -TextHandle::TextHandle() { - line_height = 0; - font = 0; - - width = height = 0; - - priority = control = 0; - halign = valign = ALIGN_BOTTOM; -} - -TextHandle::~TextHandle() { - for (uint j = 0; j < text_pixmaps.size(); j++) - if (text_pixmaps[j]) - gfx_free_pixmap(text_pixmaps[j]); -} - -void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { - int line_height; - rect_t pos; - - if (!handle) - error("Attempt to draw text with NULL handle"); - - if (handle->lines.empty()) { - debugC(2, kDebugLevelGraphics, "Skipping draw_text operation because number of lines is zero\n"); - return; - } - - _gfxop_scale_rect(&zone, state->driver->getMode()); - - line_height = handle->line_height * state->driver->getMode()->scaleFactor; - - pos.y = zone.y; - - switch (handle->valign) { - - case ALIGN_TOP: - break; - - case ALIGN_CENTER: - pos.y += (zone.height - (line_height * handle->lines.size())) >> 1; - break; - - case ALIGN_BOTTOM: - pos.y += (zone.height - (line_height * handle->lines.size())); - break; - - default: - error("Invalid vertical alignment %d", handle->valign); - } - - for (uint i = 0; i < handle->lines.size(); i++) { - - gfx_pixmap_t *pxm = handle->text_pixmaps[i]; - - if (!pxm->data) { - gfx_xlate_pixmap(pxm, state->driver->getMode()); - } - if (!pxm) - error("Could not find text pixmap %d/%d", i, handle->lines.size()); - - pos.x = zone.x; - - switch (handle->halign) { - - case ALIGN_LEFT: - break; - - case ALIGN_CENTER: - pos.x += (zone.width - pxm->width) >> 1; - break; - - case ALIGN_RIGHT: - pos.x += (zone.width - pxm->width); - break; - - default: - error("Invalid vertical alignment %d", handle->valign); - } - - pos.width = pxm->width; - pos.height = pxm->height; - - _gfxop_add_dirty(state, pos); - _gfxop_draw_pixmap(state->driver, pxm, handle->priority, handle->control, - gfx_rect(0, 0, pxm->width, pxm->height), pos, state->clip_zone, 0, state->control_map, state->priority_map); - - pos.y += line_height; - } -} - -gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { - gfx_pixmap_t *pixmap = NULL; - rect_t resultzone; // Ignored for this application - - _gfxop_scale_rect(&area, state->driver->getMode()); - _gfxop_grab_pixmap(state, &pixmap, area.x, area.y, area.width, area.height, 0, &resultzone); - - return pixmap; -} - -void gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos) { - rect_t target = gfx_rect(pos.x, pos.y, zone.width, zone.height); - - if (!pxm) - error("Attempt to draw NULL pixmap"); - - _gfxop_add_dirty(state, target); - - _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()->scaleFactor, - 200*state->driver->getMode()->scaleFactor), 0, NULL, NULL); -} - } // End of namespace Sci diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index 1e3dd41b52..2f98bfbd2e 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -28,15 +28,20 @@ #ifndef SCI_GFX_GFX_OPERATIONS_H #define SCI_GFX_GFX_OPERATIONS_H +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX #include "sci/gfx/gfx_resmgr.h" #include "sci/gfx/gfx_tools.h" #include "sci/gfx/gfx_system.h" +#endif #include "sci/uinput.h" #include "common/list.h" namespace Sci { +#ifdef INCLUDE_OLDGFX + struct TextFragment; /* Threshold in color index mode to differentiate between visible and non-visible stuff. @@ -86,8 +91,10 @@ enum gfx_box_shade_t { typedef Common::List<rect_t> DirtyRectList; +#endif // INCLUDE_OLDGFX struct GfxState { +#ifdef INCLUDE_OLDGFX rect_t clip_zone_unscaled; /**< The current UNSCALED clipping zone */ rect_t clip_zone; /**< The current SCALED clipping zone; a cached scaled version of clip_zone_unscaled */ @@ -109,15 +116,18 @@ struct GfxState { int pic_nr; /**< Number of the current pic */ int palette_nr; /**< Palette number of the current pic */ - Common::List<sci_event_t> _events; - gfxr_pic_t *pic, *pic_unscaled; /**< The background picture and its unscaled equivalent */ rect_t pic_port_bounds; /**< Picture port bounds */ DirtyRectList _dirtyRects; /**< Dirty rectangles */ +#endif + + Common::List<sci_event_t> _events; }; +#ifdef INCLUDE_OLDGFX + /** @name Fundamental operations */ /** @{ */ @@ -306,30 +316,6 @@ void gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, /** @} */ -/** @name Pointer and IO ops */ -/** @{ */ - -/** - * Suspends program execution for the specified amount of milliseconds. - * - * The mouse pointer will be redrawn continually, if applicable - * - * @param[in] state The state affected - * @param[in] msecs The amount of milliseconds to wait - */ -void gfxop_sleep(GfxState *state, uint32 msecs); - -/** - * Retrieves the next input event from the driver. - * - * @param[in] state The affected state - * @param[in] mask The event mask to poll from (see uinput.h) - * @return The next event in the driver's event queue, or a NONE event - * if no event matching the mask was found. - */ -sci_event_t gfxop_get_event(GfxState *state, unsigned int mask); -/** @} */ - /** @name View operations */ /** @{ */ @@ -537,6 +523,33 @@ void gfxdr_add_dirty(DirtyRectList &list, rect_t box); int _gfxop_clip(rect_t *rect, rect_t clipzone); /** @} */ +#endif // INCLUDE_OLDGFX + +/** @name Pointer and IO ops */ +/** @{ */ + +/** + * Suspends program execution for the specified amount of milliseconds. + * + * The mouse pointer will be redrawn continually, if applicable + * + * @param[in] state The state affected + * @param[in] msecs The amount of milliseconds to wait + */ +void gfxop_sleep(GfxState *state, uint32 msecs); + +/** + * Retrieves the next input event from the driver. + * + * @param[in] state The affected state + * @param[in] mask The event mask to poll from (see uinput.h) + * @return The next event in the driver's event queue, or a NONE event + * if no event matching the mask was found. + */ +sci_event_t gfxop_get_event(GfxState *state, unsigned int mask); +/** @} */ + + } // End of namespace Sci #endif // SCI_GFX_GFX_OPERATIONS_H diff --git a/engines/sci/gfx/palette.cpp b/engines/sci/gfx/palette.cpp index eb3382c5de..62e70e2a6d 100644 --- a/engines/sci/gfx/palette.cpp +++ b/engines/sci/gfx/palette.cpp @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #include "sci/gfx/palette.h" #include "sci/gfx/gfx_system.h" @@ -323,3 +326,5 @@ Palette *Palette::copy() { } // End of namespace Sci + +#endif diff --git a/engines/sci/gfx/palette.h b/engines/sci/gfx/palette.h index 82a447e001..b74eebd72e 100644 --- a/engines/sci/gfx/palette.h +++ b/engines/sci/gfx/palette.h @@ -23,6 +23,9 @@ * */ +#include "sci/sci.h" // for INCLUDE_OLDGFX +#ifdef INCLUDE_OLDGFX + #ifndef SCI_GFX_PALETTE_H #define SCI_GFX_PALETTE_H @@ -122,3 +125,5 @@ private: } // End of namespace Sci #endif // SCI_GFX_PALETTE_H + +#endif |