diff options
author | Filippos Karapetis | 2009-08-31 14:24:35 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-08-31 14:24:35 +0000 |
commit | cc17addebf520a9e133d75aca9756ef230869398 (patch) | |
tree | 4bcc7276e6432d3bf3df9c0b8a57b8bcf334925a /engines/sci/gfx | |
parent | 41e24b74954c416c386d1ea670e4395b8e29ce68 (diff) | |
download | scummvm-rg350-cc17addebf520a9e133d75aca9756ef230869398.tar.gz scummvm-rg350-cc17addebf520a9e133d75aca9756ef230869398.tar.bz2 scummvm-rg350-cc17addebf520a9e133d75aca9756ef230869398.zip |
Removed many bogus return values in the SCI graphics functions - some functions always returned "true", whereas in others they errored out in fatal conditions before any value was returned. FreeSCI was returning values from the graphics drivers it used. In ScummVM, we have one graphics driver, and we error out in fatal conditions anyway, so these error checks are no longer necessary, and the resulting code looks much neater
svn-id: r43851
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r-- | engines/sci/gfx/gfx_driver.cpp | 50 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_driver.h | 24 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_gui.cpp | 10 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.cpp | 58 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 336 | ||||
-rw-r--r-- | engines/sci/gfx/operations.h | 95 |
6 files changed, 182 insertions, 391 deletions
diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index b71152822c..7803fbbe11 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -87,7 +87,7 @@ static void drawProc(int x, int y, int c, void *data) { memcpy(p + (y * 320* drv->getMode()->xfact + x) * COPY_BYTES, &col, COPY_BYTES); } -int GfxDriver::drawLine(Common::Point start, Common::Point end, gfx_color_t color, +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; @@ -136,11 +136,9 @@ int GfxDriver::drawLine(Common::Point start, Common::Point end, gfx_color_t colo } } } - - return GFX_OK; } -int GfxDriver::drawFilledRect(rect_t rect, gfx_color_t color1, gfx_color_t color2, +void GfxDriver::drawFilledRect(rect_t rect, gfx_color_t color1, gfx_color_t color2, gfx_rectangle_fill_t shade_mode) { if (color1.mask & GFX_MASK_VISUAL) { for (int i = rect.y; i < rect.y + rect.height; i++) { @@ -151,38 +149,30 @@ int GfxDriver::drawFilledRect(rect_t rect, gfx_color_t color1, gfx_color_t color if (color1.mask & GFX_MASK_PRIORITY) gfx_draw_box_pixmap_i(_priority[0], rect, color1.priority); - - return GFX_OK; } // Pixmap operations -int GfxDriver::drawPixmap(gfx_pixmap_t *pxm, int priority, rect_t src, rect_t dest, gfx_buffer_t buffer) { +void GfxDriver::drawPixmap(gfx_pixmap_t *pxm, int priority, rect_t src, rect_t dest, gfx_buffer_t buffer) { int bufnr = (buffer == GFX_BUFFER_STATIC) ? 1 : 0; if (dest.width != src.width || dest.height != src.height) { - printf("Attempt to scale pixmap (%dx%d)->(%dx%d): Not supported\n", src.width, src.height, dest.width, dest.height); - return GFX_ERROR; + warning("Attempt to scale pixmap (%dx%d)->(%dx%d): Not supported\n", src.width, src.height, dest.width, dest.height); + return; } gfx_crossblit_pixmap(_mode, pxm, priority, src, dest, _visual[bufnr], _mode->xsize * _mode->bytespp, _priority[bufnr]->index_data, _priority[bufnr]->index_width, 1, 0); - - return GFX_OK; } -int GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) { - if (src.x < 0 || src.y < 0) { - printf("Attempt to grab pixmap from invalid coordinates (%d,%d)\n", src.x, src.y); - return GFX_ERROR; - } +void GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) { + if (src.x < 0 || src.y < 0) + error("Attempt to grab pixmap from invalid coordinates (%d,%d)", src.x, src.y); - if (!pxm->data) { - printf("Attempt to grab pixmap to unallocated memory\n"); - return GFX_ERROR; - } + if (!pxm->data) + error("Attempt to grab pixmap to unallocated memory"); switch (map) { @@ -197,20 +187,17 @@ int GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) { break; case GFX_MASK_PRIORITY: - printf("FIXME: priority map grab not implemented yet!\n"); + warning("FIXME: priority map grab not implemented yet"); break; default: - printf("Attempt to grab pixmap from invalid map 0x%02x\n", map); - return GFX_ERROR; + error("Attempt to grab pixmap from invalid map 0x%02x", map); } - - return GFX_OK; } // Buffer operations -int GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) { +void GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) { //TODO /* @@ -238,17 +225,12 @@ int GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) { } default: error("Invalid buffer %d in update", buffer); - return GFX_ERROR; } - - return GFX_OK; } -int GfxDriver::setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority) { +void GfxDriver::setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority) { memcpy(_visual[1], pic->data, _mode->xsize * _mode->ysize * _mode->bytespp); gfx_copy_pixmap_box_i(_priority[1], priority, gfx_rect(0, 0, _mode->xsize, _mode->ysize)); - - return GFX_OK; } // Mouse pointer operations @@ -283,7 +265,7 @@ byte *GfxDriver::createCursor(gfx_pixmap_t *pointer) { } -int GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) { +void GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) { if ((pointer == NULL) || (hotspot == NULL)) { CursorMan.showMouse(false); } else { @@ -304,8 +286,6 @@ int GfxDriver::setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot) { delete[] cursorData; cursorData = 0; } - - return GFX_OK; } } // End of namespace Sci diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h index cc8a5208d4..d12d82395e 100644 --- a/engines/sci/gfx/gfx_driver.h +++ b/engines/sci/gfx/gfx_driver.h @@ -119,9 +119,8 @@ public: * @param[in] color The color to draw with * @param[in] line_mode Any of the line modes * @param[in] line_style Any of the line styles - * @return GFX_OK or GFX_FATAL */ - int drawLine(Common::Point start, Common::Point end, gfx_color_t color, + void drawLine(Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); /** @@ -137,9 +136,8 @@ public: * @param[in] color1 The first color to draw with * @param[in] color2 The second color to draw with * @param[in] shade_mode Any of GFX_SHADE_*. - * @return GFX_OK or GFX_FATAL */ - int drawFilledRect(rect_t rect, gfx_color_t color1, gfx_color_t color2, + void drawFilledRect(rect_t rect, gfx_color_t color1, gfx_color_t color2, gfx_rectangle_fill_t shade_mode); /** @} */ @@ -156,10 +154,8 @@ public: * @param[in] src The pixmap-relative source rectangle * @param[in] dest The destination rectangle * @param[in] buffer One of GFX_BUFFER_STATIC and GFX_BUFFER_BACK - * @return GFX_OK or GFX_FATAL, or GFX_ERROR if pxm was - * not (but should have been) registered. */ - int drawPixmap(gfx_pixmap_t *pxm, int priority, + void drawPixmap(gfx_pixmap_t *pxm, int priority, rect_t src, rect_t dest, gfx_buffer_t buffer); /** @@ -170,11 +166,8 @@ public: * @param[in] src The rectangle to grab * @param[in] pxm The pixmap structure the data is to be written to * @param[in] map GFX_MASK_VISUAL or GFX_MASK_PRIORITY - * @return GFX_OK, GFX_FATAL, or GFX_ERROR for invalid map - * values pxm may be assumed to be empty and - * pre-allocated with an appropriate memory size. */ - int grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map); + void grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map); /** @} */ /** @name Buffer operations */ @@ -193,9 +186,8 @@ public: * @param[in] src: Source rectangle * @param[in] dest: Destination point * @param[in] buffer: One of GFX_BUFFER_FRONT or GFX_BUFFER_BACK - * @return GFX_OK, GFX_ERROR or GFX_FATAL */ - int update(rect_t src, Common::Point dest, gfx_buffer_t buffer); + void update(rect_t src, Common::Point dest, gfx_buffer_t buffer); /** * Sets the contents of the static visual and priority buffers. @@ -212,9 +204,8 @@ public: * visual back buffer * @param[in] priority The priority map containing the new content of * the priority back buffer in the index buffer - * @return GFX_OK or GFX_FATAL */ - int setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority); + void setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority); /** @} */ /** @name Mouse pointer operations */ @@ -232,9 +223,8 @@ public: * @param[in] pointer The pointer to set, or NULL to set no pointer. * @param[in] hotspot The coordinates of the hotspot, or NULL to set * no pointer. - * @return GFX_OK or GFX_FATAL */ - int setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot); + void setPointer(gfx_pixmap_t *pointer, Common::Point *hotspot); /** @} */ gfx_mode_t *getMode() { return _mode; } diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp index 218bf1523e..2659704d7e 100644 --- a/engines/sci/gfx/gfx_gui.cpp +++ b/engines/sci/gfx/gfx_gui.cpp @@ -220,10 +220,7 @@ GfxPort *sciw_new_window(EngineState *s, // Draw backdrop shadow if (!(flags & kWindowNoDropShadow)) { - if (gfxop_set_color(state, &black, 0, 0, 0, 0x80, bgcolor.priority, -1)) { - error("Could not get black/semitrans color entry"); - return NULL; - } + gfxop_set_color(state, &black, 0, 0, 0, 0x80, bgcolor.priority, -1); decorations->add((GfxContainer *)decorations, (GfxWidget *) gfxw_new_box(state, gfx_rect(shadow_offset + 1, frame.height - 1, @@ -236,10 +233,7 @@ GfxPort *sciw_new_window(EngineState *s, // Draw frame - if (gfxop_set_color(state, &black, 0, 0, 0, 0, bgcolor.priority, -1)) { - error("Could not get black color entry"); - return NULL; - } + gfxop_set_color(state, &black, 0, 0, 0, 0, bgcolor.priority, -1); if (!(flags & kWindowNoDropShadow)) { diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index 6a3bddee0d..fbe682bab4 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -165,17 +165,6 @@ static int verify_widget(GfxWidget *widget) { #define VERIFY_WIDGET(w) \ if (verify_widget((GfxWidget *)(w))) { error("Error occured while validating widget"); } -#define GFX_ASSERT(_x) \ -{ \ - int retval = (_x); \ - if (retval == GFX_ERROR) { \ - warning("Error occured while drawing widget"); \ - return 1; \ - } else if (retval == GFX_FATAL) { \ - error("Fatal error occured while drawing widget!\nGraphics state invalid; aborting program..."); \ - } \ -} - //********** Widgets ************* // Base class operations and common stuff @@ -334,7 +323,7 @@ static Common::Point _move_point(rect_t rect, Common::Point point) { int GfxBox::draw(const Common::Point &pos) { DRAW_ASSERT(this, GFXW_BOX); - GFX_ASSERT(gfxop_draw_box(_visual->_gfxState, _move_rect(_bounds, pos), _color1, _color2, _shadeType)); + gfxop_draw_box(_visual->_gfxState, _move_rect(_bounds, pos), _color1, _color2, _shadeType); return 0; } @@ -464,8 +453,8 @@ static int _gfxwop_primitive_equals(GfxWidget *widget, GfxWidget *other) { int GfxRect::draw(const Common::Point &pos) { DRAW_ASSERT(this, GFXW_RECT); - GFX_ASSERT(gfxop_draw_rectangle(_visual->_gfxState, gfx_rect(_bounds.x + pos.x, _bounds.y + pos.y, - _bounds.width - 1, _bounds.height - 1), _color, _lineMode, _lineStyle)); + gfxop_draw_rectangle(_visual->_gfxState, gfx_rect(_bounds.x + pos.x, _bounds.y + pos.y, + _bounds.width - 1, _bounds.height - 1), _color, _lineMode, _lineStyle); return 0; } @@ -511,7 +500,7 @@ int GfxLine::draw(const Common::Point &pos) { DRAW_ASSERT(this, GFXW_LINE); _split_rect(_move_rect(linepos, pos), &p1, &p2); - GFX_ASSERT(gfxop_draw_line(_visual->_gfxState, p1, p2, _color, _lineMode, _lineStyle)); + gfxop_draw_line(_visual->_gfxState, p1, p2, _color, _lineMode, _lineStyle); return 0; } @@ -581,14 +570,14 @@ GfxView::GfxView(GfxState *state, Common::Point pos_, int view_, int loop_, int int GfxView::draw(const Common::Point &pos) { if (_type == GFXW_VIEW) { DRAW_ASSERT(this, GFXW_VIEW); - GFX_ASSERT(gfxop_draw_cel(_visual->_gfxState, _view, _loop, _cel, - Common::Point(_pos.x + pos.x, _pos.y + pos.y), _color, _palette)); + gfxop_draw_cel(_visual->_gfxState, _view, _loop, _cel, + Common::Point(_pos.x + pos.x, _pos.y + pos.y), _color, _palette); } else { // FIXME: _gfxwop_static_view_draw checked for GFXW_VIEW here, instead of GFXW_STATIC_VIEW. //DRAW_ASSERT(this, GFXW_VIEW); DRAW_ASSERT(this, GFXW_STATIC_VIEW); - GFX_ASSERT(gfxop_draw_cel_static(_visual->_gfxState, _view, _loop, _cel, - _move_point(_bounds, pos), _color, _palette)); + gfxop_draw_cel_static(_visual->_gfxState, _view, _loop, _cel, + _move_point(_bounds, pos), _color, _palette); } return 0; } @@ -638,16 +627,16 @@ int GfxDynView::draw(const Common::Point &pos) { if (_type == GFXW_DYN_VIEW) { DRAW_ASSERT(this, GFXW_DYN_VIEW); - GFX_ASSERT(gfxop_draw_cel(_visual->_gfxState, _view, _loop, _cel, - _move_point(draw_bounds, pos), _color, _palette)); + gfxop_draw_cel(_visual->_gfxState, _view, _loop, _cel, + _move_point(draw_bounds, pos), _color, _palette); /* gfx_color_t red; red.visual.r = 0xff; red.visual.g = red.visual.b = 0; red.mask = GFX_MASK_VISUAL; - GFX_ASSERT(gfxop_draw_rectangle(view->visual->_gfxState, - gfx_rect(view->_bounds.x + pos.x, view->_bounds.y + pos.y, view->_bounds.width - 1, view->_bounds.height - 1), red, 0, 0)); + gfxop_draw_rectangle(view->visual->_gfxState, + gfx_rect(view->_bounds.x + pos.x, view->_bounds.y + pos.y, view->_bounds.width - 1, view->_bounds.height - 1), red, 0, 0); */ } else { DRAW_ASSERT(this, GFXW_PIC_VIEW); @@ -655,13 +644,13 @@ int GfxDynView::draw(const Common::Point &pos) { if (_isDrawn) return 0; - GFX_ASSERT(gfxop_set_clip_zone(_visual->_gfxState, _parent->zone)); - GFX_ASSERT(gfxop_draw_cel_static_clipped(_visual->_gfxState, _view, _loop, - _cel, _move_point(draw_bounds, pos), _color, _palette)); + gfxop_set_clip_zone(_visual->_gfxState, _parent->zone); + gfxop_draw_cel_static_clipped(_visual->_gfxState, _view, _loop, + _cel, _move_point(draw_bounds, pos), _color, _palette); // Draw again on the back buffer - GFX_ASSERT(gfxop_draw_cel(_visual->_gfxState, _view, _loop, _cel, - _move_point(draw_bounds, pos), _color, _palette)); + gfxop_draw_cel(_visual->_gfxState, _view, _loop, _cel, + _move_point(draw_bounds, pos), _color, _palette); _isDrawn = true; // No more drawing needs to be done @@ -830,7 +819,7 @@ int GfxText::draw(const Common::Point &pos) { halign, valign, _color1, _color2, _bgcolor, _textFlags); } - GFX_ASSERT(gfxop_draw_text(_visual->_gfxState, _textHandle, _move_rect(_bounds, pos))); + gfxop_draw_text(_visual->_gfxState, _textHandle, _move_rect(_bounds, pos)); return 0; } @@ -1060,7 +1049,7 @@ static int _gfxwop_container_draw_contents(GfxWidget *widget, GfxWidget *content if (seeker->_flags & GFXW_FLAG_DIRTY) { if (!GFXW_IS_CONTAINER(seeker) && draw_noncontainers) { - GFX_ASSERT(gfxop_set_clip_zone(gfx_state, small_rect)); + gfxop_set_clip_zone(gfx_state, small_rect); } /* Clip zone must be reset after each element, because we might ** descend into containers. @@ -1383,14 +1372,7 @@ int GfxVisual::draw(const Common::Point &pos) { DRAW_ASSERT(this, GFXW_VISUAL); for (DirtyRectList::iterator dirty = _dirtyRects.begin(); dirty != _dirtyRects.end(); ++dirty) { - int err = gfxop_clear_box(_gfxState, *dirty); - - if (err) { - error("Error while clearing dirty rect (%d,%d,(%dx%d))", dirty->x, - dirty->y, dirty->width, dirty->height); - if (err == GFX_FATAL) - return err; - } + gfxop_clear_box(_gfxState, *dirty); } _gfxwop_container_draw_contents(this, _contents); diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index a23bae5350..226f477b8a 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -114,7 +114,7 @@ int _gfxop_clip(rect_t *rect, rect_t clipzone) { return (rect->width <= 0 || rect->height <= 0); } -static int _gfxop_grab_pixmap(GfxState *state, gfx_pixmap_t **pxmp, int x, int y, +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; @@ -124,7 +124,7 @@ static int _gfxop_grab_pixmap(GfxState *state, gfx_pixmap_t **pxmp, int x, int y *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))) - return GFX_ERROR; + error("_gfxop_grab_pixmap: zone was empty"); if (!*pxmp) *pxmp = gfx_new_pixmap(unscaled_xl, unscaled_yl, GFX_RESID_NONE, 0, 0); @@ -139,7 +139,7 @@ static int _gfxop_grab_pixmap(GfxState *state, gfx_pixmap_t **pxmp, int x, int y (*pxmp)->index_height = unscaled_yl + 1; gfx_pixmap_alloc_data(*pxmp, state->driver->getMode()); } - return state->driver->grabPixmap(*zone, *pxmp, priority ? GFX_MASK_PRIORITY : GFX_MASK_VISUAL); + state->driver->grabPixmap(*zone, *pxmp, priority ? GFX_MASK_PRIORITY : GFX_MASK_VISUAL); } #define DRAW_LOOP(condition) \ @@ -185,9 +185,11 @@ DRAW_LOOP(map->index_data[offset] < color) // Draw only lower priority #undef DRAW_LOOP -static int _gfxop_install_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm) { - if (!driver->getMode()->palette) return GFX_OK; - if (!pxm->palette) return GFX_OK; +static void _gfxop_install_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm) { + if (!driver->getMode()->palette) + return; + if (!pxm->palette) + return; pxm->palette->mergeInto(driver->getMode()->palette); assert(pxm->palette->getParent() == driver->getMode()->palette); @@ -195,7 +197,8 @@ static int _gfxop_install_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm) { if (pxm->palette_revision != pxm->palette->getRevision()) gfx_xlate_pixmap(pxm, driver->getMode(), GFX_XLATE_FILTER_NONE); - if (!driver->getMode()->palette->isDirty()) return GFX_OK; + if (!driver->getMode()->palette->isDirty()) + return; // TODO: We probably want to only update the colours used by this pixmap // here. This will require updating the 'dirty' system. @@ -211,13 +214,10 @@ static int _gfxop_install_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm) { g_system->setPalette(paletteData, 0, paletteSize); driver->getMode()->palette->markClean(); - - return GFX_OK; } -static int _gfxop_draw_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm, int priority, int control, +static void _gfxop_draw_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm, int priority, int control, rect_t src, rect_t dest, rect_t clip, int static_buf, gfx_pixmap_t *control_map, gfx_pixmap_t *priority_map) { - int err; rect_t clipped_dest = gfx_rect(dest.x, dest.y, dest.width, dest.height); if (control >= 0 || priority >= 0) { @@ -233,28 +233,19 @@ static int _gfxop_draw_pixmap(GfxDriver *driver, gfx_pixmap_t *pxm, int priority } if (_gfxop_clip(&clipped_dest, clip)) - return GFX_OK; + return; src.x += clipped_dest.x - dest.x; src.y += clipped_dest.y - dest.y; src.width = clipped_dest.width; src.height = clipped_dest.height; - err = _gfxop_install_pixmap(driver, pxm); - if (err) - return err; + _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); - err = driver->drawPixmap(pxm, priority, src, clipped_dest, static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); - - if (err) { - error("driver->draw_pixmap() returned error code"); - return err; - } - - return GFX_OK; + driver->drawPixmap(pxm, priority, src, clipped_dest, static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK); } static void _gfxop_full_pointer_refresh(GfxState *state) { @@ -286,7 +277,7 @@ static void _gfxop_full_pointer_refresh(GfxState *state) { state->pointer_pos.y * state->driver->getMode()->yfact); } -static int _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t buffer); +static void _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t buffer); gfx_pixmap_t *_gfxr_get_cel(GfxState *state, int nr, int *loop, int *cel, int palette) { gfxr_view_t *view = state->gfxResMan->getView(nr, loop, cel, palette); @@ -312,15 +303,9 @@ gfx_pixmap_t *_gfxr_get_cel(GfxState *state, int nr, int *loop, int *cel, int pa //** Dirty rectangle operations ** -static int _gfxop_update_box(GfxState *state, rect_t box) { - int retval; +static void _gfxop_update_box(GfxState *state, rect_t box) { _gfxop_scale_rect(&box, state->driver->getMode()); - - if ((retval = _gfxop_buffer_propagate_box(state, box, GFX_BUFFER_FRONT))) { - error("Error occured while propagating box (%d,%d,%d,%d) to front buffer", box.x, box.y, box.width, box.height); - return retval; - } - return GFX_OK; + _gfxop_buffer_propagate_box(state, box, GFX_BUFFER_FRONT); } void gfxdr_add_dirty(DirtyRectList &list, rect_t box, int strategy) { @@ -401,9 +386,7 @@ static void _gfxop_add_dirty_x(GfxState *state, rect_t box) { _gfxop_add_dirty(state, box); } -static int _gfxop_clear_dirty_rec(GfxState *state, DirtyRectList &dirtyRects) { - int retval = GFX_OK; - +static void _gfxop_clear_dirty_rec(GfxState *state, DirtyRectList &dirtyRects) { DirtyRectList::iterator dirty = dirtyRects.begin(); while (dirty != dirtyRects.end()) { @@ -411,12 +394,10 @@ static int _gfxop_clear_dirty_rec(GfxState *state, DirtyRectList &dirtyRects) { fprintf(stderr, "\tClearing dirty (%d %d %d %d)\n", GFX_PRINT_RECT(*dirty)); #endif if (!state->fullscreen_override) - retval |= _gfxop_update_box(state, *dirty); + _gfxop_update_box(state, *dirty); ++dirty; } dirtyRects.clear(); - - return retval; } //** Exported operations ** @@ -427,7 +408,7 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) { (*pixmap)->palette = new Palette(default_colors, DEFAULT_COLORS_NR); } -int gfxop_init(int version, GfxState *state, +void gfxop_init(int version, GfxState *state, gfx_options_t *options, ResourceManager *resManager, Graphics::PixelFormat mode, int xfact, int yfact) { //int color_depth = bpp ? bpp : 1; @@ -455,11 +436,9 @@ int gfxop_init(int version, GfxState *state, init_aux_pixmap(&(state->control_map)); init_aux_pixmap(&(state->priority_map)); init_aux_pixmap(&(state->static_priority_map)); - - return GFX_OK; } -int gfxop_exit(GfxState *state) { +void gfxop_exit(GfxState *state) { state->gfxResMan->freeResManager(); if (state->control_map) { @@ -478,8 +457,6 @@ int gfxop_exit(GfxState *state) { } delete state->driver; - - return GFX_OK; } static int _gfxop_scan_one_bitmask(gfx_pixmap_t *pixmap, rect_t zone) { @@ -532,7 +509,7 @@ int gfxop_scan_bitmask(GfxState *state, rect_t area, gfx_map_mask_t map) { #define MAX_X 319 #define MAX_Y 199 -int gfxop_set_clip_zone(GfxState *state, rect_t zone) { +void gfxop_set_clip_zone(GfxState *state, rect_t zone) { int xfact, yfact; DDIRTY(stderr, "-- Setting clip zone %d %d %d %d\n", GFX_PRINT_RECT(zone)); @@ -562,11 +539,9 @@ int gfxop_set_clip_zone(GfxState *state, rect_t zone) { state->clip_zone.y = state->clip_zone_unscaled.y * yfact; state->clip_zone.width = state->clip_zone_unscaled.width * xfact; state->clip_zone.height = state->clip_zone_unscaled.height * yfact; - - return GFX_OK; } -int gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, int a, int priority, int control) { +void gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, int a, int priority, int control) { int mask = ((r >= 0 && g >= 0 && b >= 0) ? GFX_MASK_VISUAL : 0) | ((priority >= 0) ? GFX_MASK_PRIORITY : 0) | ((control >= 0) ? GFX_MASK_CONTROL : 0); @@ -588,13 +563,11 @@ int gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, in color->visual.parent_index = state->driver->getMode()->palette->findNearbyColor(r,g,b,true); } } - - return GFX_OK; } // Wrapper for gfxop_set_color -int gfxop_set_color(GfxState *state, gfx_color_t *colorOut, gfx_color_t &colorIn) { - return gfxop_set_color(state, colorOut, +void gfxop_set_color(GfxState *state, gfx_color_t *colorOut, gfx_color_t &colorIn) { + gfxop_set_color(state, colorOut, (colorIn.mask & GFX_MASK_VISUAL) ? colorIn.visual.r : -1, (colorIn.mask & GFX_MASK_VISUAL) ? colorIn.visual.g : -1, (colorIn.mask & GFX_MASK_VISUAL) ? colorIn.visual.b : -1, @@ -603,23 +576,19 @@ int gfxop_set_color(GfxState *state, gfx_color_t *colorOut, gfx_color_t &colorIn (colorIn.mask & GFX_MASK_CONTROL) ? colorIn.control : -1); } -int gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *color) { +void gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *color) { if (!PALETTE_MODE) - return GFX_OK; + return; if (index >= state->driver->getMode()->palette->size()) { error("Attempt to set invalid color index %02x as system color", color->visual.parent_index); - return GFX_ERROR; } state->driver->getMode()->palette->makeSystemColor(index, color->visual); - - return GFX_OK; } -int gfxop_free_color(GfxState *state, gfx_color_t *color) { +void gfxop_free_color(GfxState *state, gfx_color_t *color) { // FIXME: implement. (And call in the appropriate places!) - return GFX_OK; } @@ -717,7 +686,7 @@ static void draw_line_to_control_map(GfxState *state, Common::Point start, Commo gfx_draw_line_pixmap_i(state->control_map, start, end, color.control); } -static int simulate_stippled_line_draw(GfxDriver *driver, int skipone, Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode) { +static void simulate_stippled_line_draw(GfxDriver *driver, int skipone, Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode) { // 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; @@ -757,18 +726,12 @@ static int simulate_stippled_line_draw(GfxDriver *driver, int skipone, Common::P yl = linelength; while (length--) { - int retval; Common::Point nextpos = Common::Point(start.x + xl, start.y + yl); - - if ((retval = driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL))) { - error("Failed to draw partial stippled line (%d,%d) -- (%d,%d)", start.x, start.y, nextpos.x, nextpos.y); - return retval; - } + driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL); *posvar += delta; } if (length_left) { - int retval; Common::Point nextpos; if (length_left > stepwidth) @@ -782,18 +745,12 @@ static int simulate_stippled_line_draw(GfxDriver *driver, int skipone, Common::P nextpos = Common::Point(start.x + xl, start.y + yl); - if ((retval = driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL))) { - error("Failed to draw partial stippled line (%d,%d) -- (%d,%d)", start.x, start.y, nextpos.x, nextpos.y); - return retval; - } + driver->drawLine(start, nextpos, color, line_mode, GFX_LINE_STYLE_NORMAL); } - - return GFX_OK; } -static int _gfxop_draw_line_clipped(GfxState *state, Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, +static void _gfxop_draw_line_clipped(GfxState *state, Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { - int retval; int skipone = (start.x ^ end.y) & 1; // Used for simulated line stippling _gfxop_full_pointer_refresh(state); @@ -810,25 +767,18 @@ static int _gfxop_draw_line_clipped(GfxState *state, Common::Point start, Common || 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)) - return GFX_OK; // Clipped off + return; // Clipped off if (line_style == GFX_LINE_STYLE_STIPPLED) { - if (start.x != end.x && start.y != end.y) { - warning("[GFX] Attempt to draw stippled line which is neither an hbar nor a vbar: (%d,%d) -- (%d,%d)", start.x, start.y, end.x, end.y); - return GFX_ERROR; - } - return simulate_stippled_line_draw(state->driver, skipone, start, end, color, line_mode); - } - - if ((retval = state->driver->drawLine(start, end, color, line_mode, line_style))) { - error("Failed to draw line (%d,%d) -- (%d,%d)", start.x, start.y, end.x, end.y); - return retval; + if (start.x != end.x && start.y != end.y) + error("[GFX] Attempt to draw stippled line which is neither an hbar nor a vbar: (%d,%d) -- (%d,%d)", start.x, start.y, end.x, end.y); + simulate_stippled_line_draw(state->driver, skipone, start, end, color, line_mode); } - return GFX_OK; + state->driver->drawLine(start, end, color, line_mode, line_style); } -int gfxop_draw_line(GfxState *state, Common::Point start, Common::Point end, +void gfxop_draw_line(GfxState *state, Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { int xfact, yfact; @@ -852,11 +802,10 @@ int gfxop_draw_line(GfxState *state, Common::Point start, Common::Point end, if (color.visual.parent_index == GFX_COLOR_INDEX_UNMAPPED) gfxop_set_color(state, &color, color); - return _gfxop_draw_line_clipped(state, start, end, color, line_mode, line_style); + _gfxop_draw_line_clipped(state, start, end, color, line_mode, line_style); } -int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { - int retval = 0; +void gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { int xfact, yfact; int x, y, xl, yl; Common::Point upper_left_u, upper_right_u, lower_left_u, lower_right_u; @@ -884,7 +833,7 @@ int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_li lower_right = Common::Point(x + xl, y + yl); #define PARTIAL_LINE(pt1, pt2) \ - retval |= _gfxop_draw_line_clipped(state, pt1, pt2, color, line_mode, line_style); \ + _gfxop_draw_line_clipped(state, pt1, pt2, color, line_mode, line_style); \ draw_line_to_control_map(state, pt1##_u, pt2##_u, color); \ _gfxop_add_dirty_x(state, gfx_rect(pt1##_u.x, pt1##_u.y, pt2##_u.x - pt1##_u.x, pt2##_u.y - pt1##_u.y)) @@ -894,18 +843,12 @@ int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_li PARTIAL_LINE(lower_left, upper_left); #undef PARTIAL_LINE - if (retval) { - error("Failed to draw rectangle (%d,%d)+(%d,%d)", rect.x, rect.y, rect.width, rect.height); - return retval; - } - - return GFX_OK; } #define COLOR_MIX(type, dist) ((color1.type * dist) + (color2.type * (1.0 - dist))) -int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) { +void gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) { GfxDriver *drv = state->driver; int reverse = 0; // switch color1 and color2 float mod_offset = 0.0f, mod_breadth = 1.0f; // 0.0 to 1.0: Color adjustment @@ -930,16 +873,16 @@ int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t _gfxop_scale_rect(&box, state->driver->getMode()); if (!(color1.mask & (GFX_MASK_VISUAL | GFX_MASK_PRIORITY))) - return GFX_OK; + return; if (box.width <= 1 || box.height <= 1) { debugC(2, kDebugLevelGraphics, "Attempt to draw box with size %dx%d", box.width, box.height); - return GFX_OK; + return; } memcpy(&new_box, &box, sizeof(rect_t)); if (_gfxop_clip(&new_box, state->clip_zone)) - return GFX_OK; + return; switch (shade_type) { @@ -965,7 +908,6 @@ int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t default: error("Invalid shade type: %d", shade_type); - return GFX_ERROR; } @@ -978,11 +920,12 @@ int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t color1.control = 0; if (color1.visual.parent_index == GFX_COLOR_INDEX_UNMAPPED) gfxop_set_color(state, &color1, color1); - return drv->drawFilledRect(new_box, color1, color1, GFX_SHADE_FLAT); + drv->drawFilledRect(new_box, color1, color1, GFX_SHADE_FLAT); + return; } else { if (PALETTE_MODE) { warning("[GFX] Attempting to draw shaded box in palette mode"); - return GFX_ERROR; + return; // not critical } gfx_color_t draw_color1; // CHECKME @@ -1014,27 +957,20 @@ int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t } #undef COLOR_MIX -int gfxop_fill_box(GfxState *state, rect_t box, gfx_color_t color) { - return gfxop_draw_box(state, box, color, color, GFX_BOX_SHADE_FLAT); +void gfxop_fill_box(GfxState *state, rect_t box, gfx_color_t color) { + gfxop_draw_box(state, box, color, color, GFX_BOX_SHADE_FLAT); } -static int _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t buffer) { - int err; - +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))) - return GFX_OK; - - if ((err = state->driver->update(box, Common::Point(box.x, box.y), buffer))) { - error("Error occured while updating region (%d,%d,%d,%d) in buffer %d", box.x, box.y, box.width, box.height, buffer); - return err; - } + return; - return GFX_OK; + state->driver->update(box, Common::Point(box.x, box.y), buffer); } extern int sci0_palette; -int gfxop_clear_box(GfxState *state, rect_t box) { +void gfxop_clear_box(GfxState *state, rect_t box) { _gfxop_full_pointer_refresh(state); _gfxop_add_dirty(state, box); DDIRTY(stderr, "[] clearing box %d %d %d %d\n", GFX_PRINT_RECT(box)); @@ -1047,10 +983,10 @@ int gfxop_clear_box(GfxState *state, rect_t box) { _gfxop_scale_rect(&box, state->driver->getMode()); - return _gfxop_buffer_propagate_box(state, box, GFX_BUFFER_BACK); + _gfxop_buffer_propagate_box(state, box, GFX_BUFFER_BACK); } -int gfxop_set_visible_map(GfxState *state, gfx_map_mask_t visible_map) { +void gfxop_set_visible_map(GfxState *state, gfx_map_mask_t visible_map) { switch (visible_map) { case GFX_MASK_VISUAL: @@ -1072,64 +1008,50 @@ int gfxop_set_visible_map(GfxState *state, gfx_map_mask_t visible_map) { default: warning("Invalid display map %d selected", visible_map); - return GFX_ERROR; + return; } state->visible_map = visible_map; - - return GFX_OK; } -int gfxop_update(GfxState *state) { - int retval = _gfxop_clear_dirty_rec(state, state->_dirtyRects); +void gfxop_update(GfxState *state) { + _gfxop_clear_dirty_rec(state, state->_dirtyRects); if (state->fullscreen_override) { // We've been asked to re-draw the active full-screen image, essentially. rect_t rect = gfx_rect(0, 0, 320, 200); gfx_xlate_pixmap(state->fullscreen_override, state->driver->getMode(), GFX_XLATE_FILTER_NONE); gfxop_draw_pixmap(state, state->fullscreen_override, rect, Common::Point(0, 0)); - retval |= _gfxop_update_box(state, rect); - } - - if (retval) { - error("Clearing the dirty rectangles failed"); + _gfxop_update_box(state, rect); } if (state->tag_mode) { // This usually happens after a pic and all resources have been drawn - state->gfxResMan->freeTaggedResources(); - state->tag_mode = 0; } - - return retval; } -int gfxop_update_box(GfxState *state, rect_t box) { +void gfxop_update_box(GfxState *state, rect_t box) { if (state->disable_dirty) _gfxop_update_box(state, box); else _gfxop_add_dirty(state, box); - return gfxop_update(state); + gfxop_update(state); } -int gfxop_enable_dirty_frames(GfxState *state) { +void gfxop_enable_dirty_frames(GfxState *state) { state->disable_dirty = 0; - - return GFX_OK; } -int gfxop_disable_dirty_frames(GfxState *state) { +void gfxop_disable_dirty_frames(GfxState *state) { state->disable_dirty = 1; - - return GFX_OK; } // Pointer and IO ops -int gfxop_sleep(GfxState *state, uint32 msecs) { +void gfxop_sleep(GfxState *state, uint32 msecs) { uint32 time; const uint32 wakeup_time = g_system->getMillis() + msecs; @@ -1147,11 +1069,9 @@ int gfxop_sleep(GfxState *state, uint32 msecs) { } } - - return GFX_OK; } -static int _gfxop_set_pointer(GfxState *state, gfx_pixmap_t *pxm, Common::Point *hotspot) { +static void _gfxop_set_pointer(GfxState *state, gfx_pixmap_t *pxm, Common::Point *hotspot) { // FIXME: We may have to store this pxm somewhere, as the global palette // may change when a new PIC is loaded. The cursor has to be regenerated // from this pxm at that point. (An alternative might be to ensure the @@ -1161,26 +1081,24 @@ static int _gfxop_set_pointer(GfxState *state, gfx_pixmap_t *pxm, Common::Point pxm->palette->mergeInto(state->driver->getMode()->palette); } state->driver->setPointer(pxm, hotspot); - - return GFX_OK; } -int gfxop_set_pointer_cursor(GfxState *state, int nr) { +void gfxop_set_pointer_cursor(GfxState *state, int nr) { if (nr == GFXOP_NO_POINTER) - return _gfxop_set_pointer(state, NULL, NULL); + _gfxop_set_pointer(state, NULL, NULL); gfx_pixmap_t *new_pointer = state->gfxResMan->getCursor(nr); if (!new_pointer) { warning("[GFX] Attempt to set invalid pointer #%d\n", nr); - return GFX_ERROR; + return; } Common::Point p = Common::Point(new_pointer->xoffset, new_pointer->yoffset); - return _gfxop_set_pointer(state, new_pointer, &p); + _gfxop_set_pointer(state, new_pointer, &p); } -int gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot) { +void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot) { int real_loop = loop; int real_cel = cel; // FIXME: For now, don't palettize pointers @@ -1188,7 +1106,7 @@ int gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::P if (!new_pointer) { warning("[GFX] Attempt to set invalid pointer #%d", nr); - return GFX_ERROR; + return; } if (real_loop != loop || real_cel != cel) { @@ -1197,23 +1115,23 @@ int gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::P // Eco Quest 1 uses a 1x1 transparent cursor to hide the cursor from the user. Some scalers don't seem to support this. if (new_pointer->width < 2 || new_pointer->height < 2) - return _gfxop_set_pointer(state, NULL, NULL); + _gfxop_set_pointer(state, NULL, NULL); if (hotspot) - return _gfxop_set_pointer(state, new_pointer, hotspot); + _gfxop_set_pointer(state, new_pointer, hotspot); else { // Compute hotspot from xoffset/yoffset Common::Point p = Common::Point(new_pointer->xoffset + (new_pointer->width >> 1), new_pointer->yoffset + new_pointer->height - 1); - return _gfxop_set_pointer(state, new_pointer, &p); + _gfxop_set_pointer(state, new_pointer, &p); } } -int gfxop_set_pointer_position(GfxState *state, Common::Point pos) { +void gfxop_set_pointer_position(GfxState *state, Common::Point pos) { state->pointer_pos = pos; if (pos.x > 320 || pos.y > 200) { warning("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)", pos.x, pos.y); - return 0; // Not fatal + return; // Not fatal } g_system->warpMouse(pos.x * state->driver->getMode()->xfact, pos.y * state->driver->getMode()->yfact); @@ -1221,13 +1139,10 @@ int gfxop_set_pointer_position(GfxState *state, Common::Point pos) { // Trigger event reading to make sure the mouse coordinates will // actually have changed the next time we read them. gfxop_get_event(state, SCI_EVT_PEEK); - - return 0; } -int gfxop_set_pointer_zone(GfxState *state, Common::Rect rect) { +void gfxop_set_pointer_zone(GfxState *state, Common::Rect rect) { state->pointerZone = rect; - return GFX_OK; } #define SCANCODE_ROWS_NR 3 @@ -1685,7 +1600,7 @@ int gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, int *wi return GFX_OK; } -static int _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int static_buf, int palette) { +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; @@ -1696,7 +1611,7 @@ static int _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Co if (!view) { warning("[GFX] Attempt to draw loop/cel %d/%d in invalid view %d\n", loop, cel, nr); - return GFX_ERROR; + return; } pxm = view->loops[loop].cels[cel]; @@ -1709,35 +1624,32 @@ static int _gfxop_draw_cel_buffer(GfxState *state, int nr, int loop, int cel, Co if (!static_buf) _gfxop_add_dirty(state, gfx_rect(old_x, old_y, pxm->index_width, pxm->index_height)); - return _gfxop_draw_pixmap(state->driver, pxm, priority, control, gfx_rect(0, 0, pxm->width, pxm->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); } -int gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - return _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 0, palette); +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); } -int gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - int retval; +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()); - retval = gfxop_draw_cel_static_clipped(state, nr, loop, cel, pos, color, palette); + 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; - - return retval; } -int gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette) { - return _gfxop_draw_cel_buffer(state, nr, loop, cel, pos, color, 1, palette); +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 int _gfxop_set_pic(GfxState *state) { +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)); @@ -1755,14 +1667,14 @@ static int _gfxop_set_pic(GfxState *state) { if (state->options->pic0_unscaled) #endif state->pic->priority_map = gfx_pixmap_scale_index_data(state->pic->priority_map, state->driver->getMode()); - return state->driver->setStaticBuffer(state->pic->visual_map, state->pic->priority_map); + state->driver->setStaticBuffer(state->pic->visual_map, state->pic->priority_map); } int *gfxop_get_pic_metainfo(GfxState *state) { return (state->pic) ? state->pic->priorityTable : NULL; } -int gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { +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; @@ -1786,30 +1698,25 @@ int gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette) { error("Error occured in gfxop_new_pic()"); state->pic = state->pic_unscaled = NULL; - return GFX_ERROR; } state->pic_nr = nr; - return _gfxop_set_pic(state); + _gfxop_set_pic(state); } -int gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette) { - if (!state->pic) { +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"); - return GFX_ERROR; - } state->pic = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); - if (!state->pic) { + if (!state->pic) error("Could not add pic #%d to pic #%d", state->pic_nr, nr); - return GFX_ERROR; - } state->pic_unscaled = state->gfxResMan->addToPic(state->pic_nr, nr, flags, state->palette_nr, default_palette); - return _gfxop_set_pic(state); + _gfxop_set_pic(state); } // Text operations @@ -1864,16 +1771,11 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t 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; - int err = 0; // mapping text colors to palette - err |= gfxop_set_color(state, &color1, color1); - err |= gfxop_set_color(state, &color2, color2); - err |= gfxop_set_color(state, &bg_color, bg_color); - if (err) { - error("Unable to set up colors"); - return NULL; - } + 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); @@ -1935,10 +1837,8 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, const Common::String &t return handle; } -int gfxop_free_text(GfxState *state, TextHandle *handle) { +void gfxop_free_text(GfxState *state, TextHandle *handle) { delete handle; - - return GFX_OK; } TextHandle::TextHandle() { @@ -1957,19 +1857,17 @@ TextHandle::~TextHandle() { gfx_free_pixmap(text_pixmaps[j]); } -int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { +void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { int line_height; rect_t pos; _gfxop_full_pointer_refresh(state); - if (!handle) { + if (!handle) error("Attempt to draw text with NULL handle"); - return GFX_ERROR; - } if (handle->lines.empty()) { debugC(2, kDebugLevelGraphics, "Skipping draw_text operation because number of lines is zero\n"); - return GFX_OK; + return; } _gfxop_scale_rect(&zone, state->driver->getMode()); @@ -1993,7 +1891,6 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { default: error("Invalid vertical alignment %d", handle->valign); - return GFX_FATAL; // Internal error... } for (uint i = 0; i < handle->lines.size(); i++) { @@ -2007,10 +1904,8 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { gfx_xlate_pixmap(pxm, state->driver->getMode(), GFX_XLATE_FILTER_NONE); #endif } - if (!pxm) { + if (!pxm) error("Could not find text pixmap %d/%d", i, handle->lines.size()); - return GFX_ERROR; - } pos.x = zone.x; @@ -2029,7 +1924,6 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { default: error("Invalid vertical alignment %d", handle->valign); - return GFX_FATAL; // Internal error... } pos.width = pxm->width; @@ -2041,8 +1935,6 @@ int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) { pos.y += line_height; } - - return GFX_OK; } gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { @@ -2051,31 +1943,20 @@ gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) { _gfxop_full_pointer_refresh(state); _gfxop_scale_rect(&area, state->driver->getMode()); - if (_gfxop_grab_pixmap(state, &pixmap, area.x, area.y, area.width, area.height, 0, &resultzone)) - return NULL; // area CUT the visual screen had a null or negative size + _gfxop_grab_pixmap(state, &pixmap, area.x, area.y, area.width, area.height, 0, &resultzone); return pixmap; } -int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos) { - rect_t target; +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) { + if (!pxm) error("Attempt to draw NULL pixmap"); - return GFX_ERROR; - } _gfxop_full_pointer_refresh(state); - - target = gfx_rect(pos.x, pos.y, zone.width, zone.height); - _gfxop_add_dirty(state, target); - if (!pxm) { - error("Attempt to draw_pixmap with pxm=NULL"); - return GFX_ERROR; - } - _gfxop_scale_rect(&zone, state->driver->getMode()); _gfxop_scale_rect(&target, state->driver->getMode()); @@ -2083,9 +1964,8 @@ int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::P 200*state->driver->getMode()->yfact), 0, NULL, NULL); } -int gfxop_free_pixmap(GfxState *state, gfx_pixmap_t *pxm) { +void gfxop_free_pixmap(GfxState *state, gfx_pixmap_t *pxm) { gfx_free_pixmap(pxm); - return GFX_OK; } } // End of namespace Sci diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index 865b420681..5419388eb2 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -142,11 +142,8 @@ struct GfxState { * @param[in] mode Graphics mode to use * @param[in] options Rendering options * @param[in] resManager Resource manager to use - * @return GFX_OK on success, GFX_ERROR if that particular mode - * is unavailable, or GFX_FATAL if the graphics driver - * is unable to provide any useful graphics support */ -int gfxop_init(int version, GfxState *state, +void gfxop_init(int version, GfxState *state, gfx_options_t *options, ResourceManager *resManager, Graphics::PixelFormat mode, int xfact = 1, int yfact = 1); @@ -154,9 +151,8 @@ int gfxop_init(int version, GfxState *state, * Deinitializes a currently active driver. * * @param[in] state The state encapsulating the driver in question - * @return GFX_OK */ -int gfxop_exit(GfxState *state); +void gfxop_exit(GfxState *state); /** * Calculates a bit mask calculated from some pixels on the specified @@ -186,18 +182,16 @@ int gfxop_scan_bitmask(GfxState *state, rect_t area, gfx_map_mask_t map); * * @param[in] state The state to modify * @param[in] map The GFX_MASK to set - * @return GFX_OK, or GFX_ERROR if map was invalid */ -int gfxop_set_visible_map(GfxState *state, gfx_map_mask_t map); +void gfxop_set_visible_map(GfxState *state, gfx_map_mask_t map); /** * Sets a new clipping zone. * * @param[in] state The affected state * @param[in] zone The new clipping zone - * @return GFX_OK */ -int gfxop_set_clip_zone(GfxState *state, rect_t zone); +void gfxop_set_clip_zone(GfxState *state, rect_t zone); /** @} */ @@ -213,9 +207,8 @@ int gfxop_set_clip_zone(GfxState *state, rect_t zone); * @param[in] color The color to use for drawing * @param[in] line_mode Any valid line mode to use * @param[in] line_style The line style to use - * @return GFX_OK or GFX_FATAL */ -int gfxop_draw_line(GfxState *state, +void gfxop_draw_line(GfxState *state, Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); @@ -229,9 +222,8 @@ int gfxop_draw_line(GfxState *state, * @param[in] color The color the box is to be drawn in * @param[in] line_mode The line mode to use * @param[in] line_style The line style to use for the box - * @return GFX_OK or GFX_FATAL */ -int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, +void gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); /** @@ -244,9 +236,8 @@ int gfxop_draw_rectangle(GfxState *state, rect_t rect, gfx_color_t color, * @param[in] color1 The primary color to use for drawing * @param[in] color2 The secondary color to draw in * @param[in] shade_type The shading system to use (e.g. GFX_BOX_SHADE_FLAT) - * @return GFX_OK or GFX_FATAL */ -int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, +void gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type); /** @@ -257,18 +248,16 @@ int gfxop_draw_box(GfxState *state, rect_t box, gfx_color_t color1, * @param[in] state The state to draw to * @param[in] box The box to fill * @param[in] color The color to use for filling - * @return GFX_OK or GFX_FATAL */ -int gfxop_fill_box(GfxState *state, rect_t box, gfx_color_t color); +void gfxop_fill_box(GfxState *state, rect_t box, gfx_color_t color); /** * Copies a box from the static buffer to the back buffer. * * @param[in] state The affected state * @param[in] box The box to propagate from the static buffer - * @return GFX_OK or GFX_FATAL */ -int gfxop_clear_box(GfxState *state, rect_t box); +void gfxop_clear_box(GfxState *state, rect_t box); /** @@ -279,9 +268,8 @@ int gfxop_clear_box(GfxState *state, rect_t box); * occasions (see gfxop_new_pic). * * @param[in] state The relevant state - * @return GFX_OK or GFX_FATAL if reported by the driver */ -int gfxop_update(GfxState *state); +void gfxop_update(GfxState *state); /** @@ -294,9 +282,8 @@ int gfxop_update(GfxState *state); * * @param[in] state The affected state * @param[in] box The box to propagate to the front buffer - * @return GFX_OK or GFX_FATAL */ -int gfxop_update_box(GfxState *state, rect_t box); +void gfxop_update_box(GfxState *state, rect_t box); /** * Enables dirty frame accounting. @@ -304,17 +291,15 @@ int gfxop_update_box(GfxState *state, rect_t box); * Dirty frame accounting is enabled by default. * * @param[in] state The state dirty frame accounting is to be enabled in - * @return GFX_OK or GFX_ERROR if state was invalid */ -int gfxop_enable_dirty_frames(GfxState *state); +void gfxop_enable_dirty_frames(GfxState *state); /** * Disables dirty frame accounting. * * @param[in] state The state dirty frame accounting is to be disabled in - * @return GFX_OK or GFX_ERROR if state was invalid */ -int gfxop_disable_dirty_frames(GfxState *state); +void gfxop_disable_dirty_frames(GfxState *state); /** @} */ @@ -344,9 +329,8 @@ int gfxop_disable_dirty_frames(GfxState *state); * @param[in] priority The priority to use for drawing, or -1 for none * @param[in] control The control to use for drawing, or -1 to disable drawing * to the control map - * @return GFX_OK or GFX_ERROR if state is invalid */ -int gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, +void gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, int a, int priority, int control); /** @@ -357,9 +341,8 @@ int gfxop_set_color(GfxState *state, gfx_color_t *color, int r, int g, int b, * @param[in] state The affected state * @param[in] index The index for the new system color * @param[in] color The color to designate as a system color - * @return GFX_OK or GFX_ERROR if state is invalid */ -int gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *color); +void gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *color); /** * Frees a color allocated by gfxop_set_color(). @@ -368,9 +351,8 @@ int gfxop_set_system_color(GfxState *state, unsigned int index, gfx_color_t *col * * @param[in] state The state affected * @param[in] color The color to de-allocate - * @return GFX_OK or GFX_ERROR if state is invalid */ -int gfxop_free_color(GfxState *state, gfx_color_t *color); +void gfxop_free_color(GfxState *state, gfx_color_t *color); /** @} */ /** @name Pointer and IO ops */ @@ -383,21 +365,16 @@ int gfxop_free_color(GfxState *state, gfx_color_t *color); * * @param[in] state The state affected * @param[in] msecs The amount of milliseconds to wait - * @return GFX_OK or GFX_ERROR */ -int gfxop_sleep(GfxState *state, uint32 msecs); +void gfxop_sleep(GfxState *state, uint32 msecs); /** * Sets the mouse pointer to a cursor resource. * * @param[in] state The affected state * @param[in] nr Number of the cursor resource to use - * @return GFX_OK, GFX_ERROR if the resource did not exist and was not - * GFXOP_NO_POINTER, or GFX_FATAL on fatal error conditions. - * Use nr = GFX_NO_POINTER to disable the mouse pointer - * (default). */ -int gfxop_set_pointer_cursor(GfxState *state, int nr); +void gfxop_set_pointer_cursor(GfxState *state, int nr); /** * Sets the mouse pointer to a view resource. @@ -409,9 +386,8 @@ int gfxop_set_pointer_cursor(GfxState *state, int nr); * @param[in] loop View loop to use * @param[in] cel View cel to use * @param[in] hotspot Manually set hotspot to use, or NULL for default. - * @return GFX_OK or GFX_FATAL */ -int gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot); +void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot); /** * Teleports the mouse pointer to a specific position. @@ -420,18 +396,16 @@ int gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::P * * @param[in] state The state the pointer is in * @param[in] pos The position to teleport it to - * @return Any error code or GFX_OK */ -int gfxop_set_pointer_position(GfxState *state, Common::Point pos); +void gfxop_set_pointer_position(GfxState *state, Common::Point pos); /** * Limits the mouse movement to a given rectangle. * * @param[in] state The affected state * @param[in] rect The rectangle - * @return Any error code or GFX_OK */ -int gfxop_set_pointer_zone(GfxState *state, Common::Rect rect); +void gfxop_set_pointer_zone(GfxState *state, Common::Rect rect); /** * Retrieves the next input event from the driver. @@ -521,9 +495,8 @@ int gfxop_get_cel_parameters(GfxState *state, int nr, int loop, int cel, * @param[in] pos The positino the cel is to be drawn to * @param[in] color The priority and control values to use for drawing * @param[in] palette The palette to use - * @return GFX_OK or GFX_FATAL */ -int gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, +void gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette); @@ -539,9 +512,8 @@ int gfxop_draw_cel(GfxState *state, int nr, int loop, int cel, * @param[in] pos The positino the cel is to be drawn to * @param[in] color The priority and control values to use for drawing * @param[in] palette The palette to use - * @return GFX_OK or GFX_FATAL */ -int gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, +void gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette); @@ -557,9 +529,8 @@ int gfxop_draw_cel_static(GfxState *state, int nr, int loop, int cel, * @param[in] pos The positino the cel is to be drawn to * @param[in] color The priority and control values to use for drawing * @param[in] palette The palette to use - * @return GFX_OK or GFX_FATAL */ -int gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, +void gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, Common::Point pos, gfx_color_t color, int palette); /** @} */ @@ -578,9 +549,8 @@ int gfxop_draw_cel_static_clipped(GfxState *state, int nr, int loop, int cel, * @param[in] nr Number of the pic to draw * @param[in] flags Interpreter-dependant flags to use for drawing * @param[in] default_palette The default palette for drawing - * @return GFX_OK or GFX_FATAL */ -int gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette); +void gfxop_new_pic(GfxState *state, int nr, int flags, int default_palette); /** * Retrieves all meta-information assigned to the current pic. @@ -599,9 +569,8 @@ int *gfxop_get_pic_metainfo(GfxState *state); * @param[in] nr Number of the pic to add * @param[in] flags Interpreter-dependant flags to use for drawing * @param[in] default_palette The default palette for drawing - * @return GFX_OK or GFX_FATAL */ -int gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette); +void gfxop_add_to_pic(GfxState *state, int nr, int flags, int default_palette); /** @} */ @@ -670,9 +639,8 @@ TextHandle *gfxop_new_text(GfxState *state, int font_nr, * * @param[in] state The state to use * @param[in] handle The handle to free - * @return GFX_OK */ -int gfxop_free_text(GfxState *state, TextHandle *handle); +void gfxop_free_text(GfxState *state, TextHandle *handle); /** * Draws text stored in a text handle. @@ -682,9 +650,8 @@ int gfxop_free_text(GfxState *state, TextHandle *handle); * @param[in] zone The rectangular box to draw to. In combination with * halign and valign, this defines where the text is drawn * to. - * @return GFX_OK or GFX_FATAL */ -int gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone); +void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone); /** @} */ @@ -709,9 +676,8 @@ gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area); * @param[in] pxm The pixmap to draw * @param[in] zone The segment of the pixmap to draw * @param[in] pos The position the pixmap should be drawn to - * @return GFX_OK or any error code */ -int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, +void gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, Common::Point pos); /** @@ -719,9 +685,8 @@ int gfxop_draw_pixmap(GfxState *state, gfx_pixmap_t *pxm, rect_t zone, * * @param[in] state The affected state * @param[in] pxm The pixmap to free - * @return GFX_OK, or GFX_ERROR if the state was invalid */ -int gfxop_free_pixmap(GfxState *state, gfx_pixmap_t *pxm); +void gfxop_free_pixmap(GfxState *state, gfx_pixmap_t *pxm); /** @} */ |