From df29b0067e100e97f29d286178685257816f0972 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 6 Oct 2009 12:26:13 +0000 Subject: - Unified the screen buffers that are used by the current and the new GUI - Replaced the FreeSCI line drawing code (which is actually Bresenham) with Graphics::drawLine(), after discussing with waltervn. This shouldn't bring any regressions, as we're no longer offering the option to scale the background at a vector level. After playing through some of the games, I haven't noticed any regressions - Some cleanup svn-id: r44692 --- engines/sci/gfx/gfx_driver.cpp | 100 ++++++++++++++++------------------------ engines/sci/gfx/gfx_driver.h | 9 ++-- engines/sci/gfx/gfx_resmgr.cpp | 1 + engines/sci/gfx/gfx_resource.h | 1 + engines/sci/gfx/gfx_support.cpp | 75 ++++-------------------------- engines/sci/gfx/gfx_tools.cpp | 7 +-- engines/sci/gfx/gfx_tools.h | 5 +- engines/sci/gfx/operations.cpp | 4 +- engines/sci/gfx/operations.h | 5 +- engines/sci/gfx/res_pic.cpp | 5 +- engines/sci/gui/gui.cpp | 5 +- engines/sci/gui/gui.h | 2 +- engines/sci/gui/gui_screen.cpp | 23 +++++---- engines/sci/gui/gui_screen.h | 8 ++-- engines/sci/gui32/gui32.cpp | 2 +- engines/sci/gui32/gui32.h | 2 +- engines/sci/sci.cpp | 9 ++-- 17 files changed, 93 insertions(+), 170 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/gfx/gfx_driver.cpp b/engines/sci/gfx/gfx_driver.cpp index ccf15f3e30..1d8eb6f01f 100644 --- a/engines/sci/gfx/gfx_driver.cpp +++ b/engines/sci/gfx/gfx_driver.cpp @@ -30,50 +30,23 @@ #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" +#include "sci/gui/gui_screen.h" namespace Sci { -GfxDriver::GfxDriver(int xfact, int yfact) { - int i; - - _mode = gfx_new_mode(xfact, yfact, new Palette(256)); - _mode->xsize = xfact * 320; - _mode->ysize = yfact * 200; - for (i = 0; i < 2; i++) { - _priority[i] = gfx_pixmap_alloc_index_data(gfx_new_pixmap(_mode->xsize, _mode->ysize, GFX_RESID_NONE, -i, -777)); - if (!_priority[i]) { - error("Out of memory: Could not allocate priority maps! (%dx%d)\n", _mode->xsize, _mode->ysize); - } - } - // create the visual buffers - for (i = 0; i < 2; i++) { - _visual[i] = NULL; - _visual[i] = new byte[_mode->xsize * _mode->ysize]; - if (!_visual[i]) { - error("Out of memory: Could not allocate visual buffers! (%dx%d)\n", _mode->xsize, _mode->ysize); - } - memset(_visual[i], 0, _mode->xsize * _mode->ysize); - } +GfxDriver::GfxDriver(SciGuiScreen *screen, int scaleFactor) : _screen(screen) { + _mode = gfx_new_mode(scaleFactor, new Palette(256)); if (_mode->palette) _mode->palette->name = "global"; } GfxDriver::~GfxDriver() { - int i; - for (i = 0; i < 2; i++) { - gfx_free_pixmap(_priority[i]); - _priority[i] = NULL; - } - - for (i = 0; i < 2; i++) { - delete[] _visual[i]; - _visual[i] = NULL; - } } @@ -81,9 +54,16 @@ GfxDriver::~GfxDriver() { static void drawProc(int x, int y, int c, void *data) { GfxDriver *drv = (GfxDriver *)data; - byte *p = drv->getVisual0(); + byte *p = drv->_screen->_displayScreen; uint8 col = c; - memcpy(p + (y * 320* drv->getMode()->scaleFactor + x), &col, 1); + memcpy(p + (y * drv->_screen->_width * drv->getMode()->scaleFactor + x), &col, 1); +} + +static void drawProcPriority(int x, int y, int c, void *data) { + GfxDriver *drv = (GfxDriver *)data; + byte *p = drv->_screen->_priorityScreen; + uint8 col = c; + memcpy(p + (y * drv->_screen->_width + x), &col, 1); } void GfxDriver::drawLine(Common::Point start, Common::Point end, gfx_color_t color, @@ -107,7 +87,7 @@ void GfxDriver::drawLine(Common::Point start, Common::Point end, gfx_color_t col Graphics::drawLine(nstart.x, nstart.y, nend.x, nend.y, scolor, drawProc, this); if (color.mask & GFX_MASK_PRIORITY) { - gfx_draw_line_pixmap_i(_priority[0], nstart, nend, color.priority); + Graphics::drawLine(nstart.x, nstart.y, nend.x, nend.y, color.priority, drawProcPriority, this); } } } @@ -118,29 +98,31 @@ void GfxDriver::drawFilledRect(rect_t rect, gfx_color_t color1, gfx_color_t colo gfx_rectangle_fill_t shade_mode) { if (color1.mask & GFX_MASK_VISUAL) { for (int i = rect.y; i < rect.y + rect.height; i++) { - memset(_visual[0] + (i * _mode->xsize + rect.x), + memset(_screen->_displayScreen + (i * _mode->xsize + rect.x), color1.visual.getParentIndex(), rect.width); } } - if (color1.mask & GFX_MASK_PRIORITY) - gfx_draw_box_pixmap_i(_priority[0], rect, color1.priority); + if (color1.mask & GFX_MASK_PRIORITY) { + gfx_clip_box_basic(&rect, _screen->_width - 1, _screen->_height - 1); + gfx_draw_box_buffer(_screen->_priorityScreen, _screen->_width, rect, color1.priority); + } } // Pixmap operations 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; - + byte *destBuffer = (buffer == GFX_BUFFER_STATIC) ? _screen->_visualScreen : _screen->_displayScreen; + byte *destPriority = (buffer == GFX_BUFFER_STATIC) ? _screen->_controlScreen : _screen->_priorityScreen; if (dest.width != src.width || dest.height != src.height) { 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], + gfx_crossblit_pixmap(_mode, pxm, priority, src, dest, destBuffer, _mode->xsize, - _priority[bufnr]->index_data, - _priority[bufnr]->index_width, 1, 0); + destPriority, + _screen->_width, 1, 0); } void GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) { @@ -157,7 +139,7 @@ void GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) { pxm->height = src.height; for (int i = 0; i < src.height; i++) { memcpy(pxm->data + i * src.width, - _visual[0] + ((i + src.y) * _mode->xsize + src.x), + _screen->_displayScreen + ((i + src.y) * _mode->xsize + src.x), src.width); } break; @@ -174,28 +156,26 @@ void GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) { // Buffer operations void GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) { - //TODO - - /* - if (src.x != dest.x || src.y != dest.y) { - printf("Updating %d (%d,%d)(%dx%d) to (%d,%d) on %d\n", buffer, src.x, src.y, src.width, src.height, dest.x, dest.y, data_dest); - } else { - printf("Updating %d (%d,%d)(%dx%d) to %d\n", buffer, src.x, src.y, src.width, src.height, data_dest); - } - */ - switch (buffer) { case GFX_BUFFER_BACK: for (int i = 0; i < src.height; i++) { - memcpy(_visual[0] + ( (dest.y + i) * _mode->xsize + dest.x), - _visual[1] + ( (src.y + i) * _mode->xsize + src.x), src.width ); + memcpy(_screen->_displayScreen + ( (dest.y + i) * _mode->xsize + dest.x), + _screen->_visualScreen + ( (src.y + i) * _mode->xsize + src.x), src.width ); } - if ((src.x == dest.x) && (src.y == dest.y)) - gfx_copy_pixmap_box_i(_priority[0], _priority[1], src); + if ((src.x == dest.x) && (src.y == dest.y)) { + int offset = src.x + (src.y * _screen->_width); + + gfx_clip_box_basic(&src, _screen->_width, _screen->_height); + + while (src.height--) { + memcpy(_screen->_priorityScreen + offset, _screen->_controlScreen + offset, _screen->_width); + offset += _screen->_width; + } + } break; case GFX_BUFFER_FRONT: { - g_system->copyRectToScreen(_visual[0] + (src.x + src.y * _mode->xsize), _mode->xsize, dest.x, dest.y, src.width, src.height); + g_system->copyRectToScreen(_screen->_displayScreen + (src.x + src.y * _mode->xsize), _mode->xsize, dest.x, dest.y, src.width, src.height); g_system->updateScreen(); break; } @@ -205,8 +185,8 @@ void GfxDriver::update(rect_t src, Common::Point dest, gfx_buffer_t buffer) { } void GfxDriver::setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority) { - memcpy(_visual[1], pic->data, _mode->xsize * _mode->ysize); - gfx_copy_pixmap_box_i(_priority[1], priority, gfx_rect(0, 0, _mode->xsize, _mode->ysize)); + memcpy(_screen->_visualScreen, pic->data, _mode->xsize * _mode->ysize); + memcpy(_screen->_controlScreen, priority->index_data, _mode->xsize * _mode->ysize); } // Mouse pointer operations diff --git a/engines/sci/gfx/gfx_driver.h b/engines/sci/gfx/gfx_driver.h index 1143d8e66d..19cd2f314f 100644 --- a/engines/sci/gfx/gfx_driver.h +++ b/engines/sci/gfx/gfx_driver.h @@ -29,8 +29,6 @@ #include "sci/gfx/gfx_system.h" #include "sci/uinput.h" -#include "graphics/pixelformat.h" - namespace Sci { enum gfx_buffer_t { @@ -85,7 +83,7 @@ public: * not be set, or GFX_FATAL if the graphics target * is unuseable. */ - GfxDriver(int xfact, int yfact); + GfxDriver(SciGuiScreen *screen, int scaleFactor); /** * Uninitializes the current graphics mode. @@ -226,16 +224,15 @@ public: /** @} */ gfx_mode_t *getMode() { return _mode; } - byte *getVisual0() { return _visual[0]; } /** * Animates palette */ void animatePalette(int fromColor, int toColor, int stepCount); +public: // temporary hack + SciGuiScreen *_screen; private: - gfx_pixmap_t *_priority[2]; - byte *_visual[2]; gfx_mode_t *_mode; /**< Currently active mode, NULL if no mode is active */ }; diff --git a/engines/sci/gfx/gfx_resmgr.cpp b/engines/sci/gfx/gfx_resmgr.cpp index f81f9e0dc1..ad1172fefc 100644 --- a/engines/sci/gfx/gfx_resmgr.cpp +++ b/engines/sci/gfx/gfx_resmgr.cpp @@ -32,6 +32,7 @@ #include "sci/sci.h" #include "sci/gfx/gfx_resource.h" #include "sci/gfx/gfx_tools.h" +#include "sci/gui/gui_screen.h" #include "sci/gfx/gfx_driver.h" #include "sci/gfx/gfx_resmgr.h" #include "sci/gfx/gfx_state_internal.h" diff --git a/engines/sci/gfx/gfx_resource.h b/engines/sci/gfx/gfx_resource.h index 753e966dd6..0bb5265bdf 100644 --- a/engines/sci/gfx/gfx_resource.h +++ b/engines/sci/gfx/gfx_resource.h @@ -31,6 +31,7 @@ #define SCI_GFX_GFX_RESOURCE_H #include "sci/gfx/gfx_system.h" +#include "sci/gui/gui_screen.h" #include "sci/gfx/gfx_driver.h" #include "common/rect.h" diff --git a/engines/sci/gfx/gfx_support.cpp b/engines/sci/gfx/gfx_support.cpp index fa3b94835a..2529fde35b 100644 --- a/engines/sci/gfx/gfx_support.cpp +++ b/engines/sci/gfx/gfx_support.cpp @@ -30,78 +30,19 @@ #include "sci/gfx/gfx_system.h" #include "sci/gfx/gfx_tools.h" -namespace Sci { - -#define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \ - linearend, nonlinearstart, linearmod, nonlinearmod) \ - incrNE = ((deltalinear) > 0) ? (deltalinear) : -(deltalinear); \ - incrNE <<= 1; \ - deltanonlinear <<= 1; \ - incrE = ((deltanonlinear) > 0) ? -(deltanonlinear) : (deltanonlinear); \ - d = nonlinearstart - 1; \ - while (linearvar != (linearend)) { \ - memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH); \ - linearvar += linearmod; \ - if ((d += incrE) < 0) { \ - d += incrNE; \ - nonlinearvar += nonlinearmod; \ - }; \ - }; \ - memcpy(buffer + linewidth * (starty) + (startx), &color, PIXELWIDTH); - - -template -void _gfx_draw_line_buffer(byte *buffer, int linewidth, Common::Point start, Common::Point end, unsigned int color) { - int incrE, incrNE, d; - int dx = ABS(end.x - start.x); - int dy = ABS(end.y - start.y); -#ifdef SCUMM_BIG_ENDIAN - color = SWAP_BYTES_32(color); -#endif +#include "graphics/primitives.h" - if (dx > dy) { - int sign1 = (end.x < start.x) ? -1 : 1; - int sign2 = (end.y < start.y) ? -1 : 1; - LINEMACRO(start.x, start.y, dx, dy, start.x, start.y, end.x, dx, sign1 * PIXELWIDTH, sign2); - } else { // dx <= dy - int sign1 = (end.y < start.y) ? -1 : 1; - int sign2 = (end.x < start.x) ? -1 : 1; - LINEMACRO(start.x, start.y, dy, dx, start.y, start.x, end.y, dy, sign1, sign2 * PIXELWIDTH); - } -} - -#undef LINEMACRO - - -static void gfx_draw_line_buffer(byte *buffer, int linewidth, int pixelwidth, - Common::Point start, Common::Point end, unsigned int color) { - switch (pixelwidth) { - - case 1: - _gfx_draw_line_buffer<1>(buffer, linewidth, start, end, color); - return; - - case 2: - _gfx_draw_line_buffer<2>(buffer, linewidth, start, end, color); - return; - - case 3: - _gfx_draw_line_buffer<3>(buffer, linewidth, start, end, color); - return; - - case 4: - _gfx_draw_line_buffer<4>(buffer, linewidth, start, end, color); - return; - - default: - error("pixelwidth=%d not supported", pixelwidth); - return; +namespace Sci { - } +static void drawProc(int x, int y, int c, void *data) { + gfx_pixmap_t *pxm = (gfx_pixmap_t *)data; + byte *p = pxm->index_data; + uint8 col = c; + memcpy(p + (y * pxm->index_width + x), &col, 1); } void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color) { - gfx_draw_line_buffer(pxm->index_data, pxm->index_width, 1, start, end, color); + Graphics::drawLine(start.x, start.y, end.x, end.y, color, drawProc, pxm); } void gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) { diff --git a/engines/sci/gfx/gfx_tools.cpp b/engines/sci/gfx/gfx_tools.cpp index 5df8f4a97c..290759374b 100644 --- a/engines/sci/gfx/gfx_tools.cpp +++ b/engines/sci/gfx/gfx_tools.cpp @@ -43,11 +43,12 @@ void gfx_clip_box_basic(rect_t *box, int maxx, int maxy) { box->height = maxy - box->y + 1; } -gfx_mode_t *gfx_new_mode(int xfact, int yfact, Palette *palette) { +gfx_mode_t *gfx_new_mode(int scaleFactor, Palette *palette) { gfx_mode_t *mode = (gfx_mode_t *)malloc(sizeof(gfx_mode_t)); - mode->scaleFactor = xfact; - mode->scaleFactor = yfact; + mode->scaleFactor = scaleFactor; + mode->xsize = scaleFactor * 320; + mode->ysize = scaleFactor * 200; mode->palette = palette; return mode; diff --git a/engines/sci/gfx/gfx_tools.h b/engines/sci/gfx/gfx_tools.h index 0abf5e26e7..6de6b81afc 100644 --- a/engines/sci/gfx/gfx_tools.h +++ b/engines/sci/gfx/gfx_tools.h @@ -29,6 +29,7 @@ #include "graphics/pixelformat.h" #include "sci/gfx/gfx_system.h" +#include "sci/gui/gui_screen.h" #include "sci/gfx/gfx_driver.h" namespace Sci { @@ -44,7 +45,7 @@ namespace Sci { * @param[in] palette Number of palette colors, 0 if we're not in palette mode * @return A newly allocated gfx_mode_t structure */ -gfx_mode_t *gfx_new_mode(int xfact, int yfact, Palette *palette); +gfx_mode_t *gfx_new_mode(int scaleFactor, Palette *palette); /** * Clips a rect_t @@ -154,6 +155,8 @@ void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, */ void gfx_draw_box_pixmap_i(gfx_pixmap_t *pxm, rect_t box, int color); +void gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color); + /** * Copies part of a pixmap to another pixmap, with clipping * diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 65fdfc1de7..8e6db7895a 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -386,7 +386,7 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) { void gfxop_init(GfxState *state, gfx_options_t *options, ResourceManager *resMan, - int xfact, int yfact) { + SciGuiScreen *screen, int scaleFactor) { state->options = options; state->visible_map = GFX_MASK_VISUAL; state->fullscreen_override = NULL; // No magical override @@ -399,7 +399,7 @@ void gfxop_init(GfxState *state, state->pic_port_bounds = gfx_rect(0, 10, 320, 190); state->_dirtyRects.clear(); - state->driver = new GfxDriver(xfact, yfact); + state->driver = new GfxDriver(screen, scaleFactor); state->gfxResMan = new GfxResManager(state->options, state->driver, resMan); diff --git a/engines/sci/gfx/operations.h b/engines/sci/gfx/operations.h index f20bbf176a..84dace4394 100644 --- a/engines/sci/gfx/operations.h +++ b/engines/sci/gfx/operations.h @@ -136,15 +136,14 @@ struct GfxState { * Initializes a graphics mode. * * @param[in] state The state to initialize - * @param[in] xfact Horizontal scale factor - * @param[in] yfact Vertical scale factors + * @param[in] scaleFactor Scale factor * @param[in] mode Graphics mode to use * @param[in] options Rendering options * @param[in] resMan Resource manager to use */ void gfxop_init(GfxState *state, gfx_options_t *options, ResourceManager *resMan, - int xfact = 1, int yfact = 1); + SciGuiScreen *screen, int scaleFactor = 1); /** * Deinitializes a currently active driver. diff --git a/engines/sci/gfx/res_pic.cpp b/engines/sci/gfx/res_pic.cpp index cb628b94ef..0196ad57a4 100644 --- a/engines/sci/gfx/res_pic.cpp +++ b/engines/sci/gfx/res_pic.cpp @@ -1485,8 +1485,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size, view->index_height = CLIP(view->index_height, 0, portBounds.height()); // Set up mode structure for resizing the view - gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, - pic->visual_map->index_height / 200, view->palette); + gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, view->palette); gfx_xlate_pixmap(view, mode); gfx_free_mode(mode); @@ -1590,7 +1589,7 @@ void gfxr_draw_pic11(gfxr_pic_t *pic, int flags, int default_palette, int size, view->palette = pic->visual_map->palette->getref(); // Set up mode structure for resizing the view - gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, pic->visual_map->index_height / 200, view->palette); + gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, view->palette); gfx_xlate_pixmap(view, mode); gfx_free_mode(mode); diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index e08f231286..4bbeb14bf6 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -38,9 +38,8 @@ namespace Sci { -SciGui::SciGui(OSystem *system, EngineState *state) - : _system(system), _s(state) { - _screen = new SciGuiScreen(_system, _s); +SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen) + : _system(system), _s(state), _screen(screen) { _gfx = new SciGuiGfx(_system, _s, _screen); _windowMgr = new SciGuiWindowMgr(_s, _gfx); } diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index e95ae8c58a..a12449e5ca 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -36,7 +36,7 @@ class SciGuiresources; class SciGuiWindowMgr; class SciGui { public: - SciGui(OSystem *system, EngineState *s); + SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen); SciGui(); virtual ~SciGui(); diff --git a/engines/sci/gui/gui_screen.cpp b/engines/sci/gui/gui_screen.cpp index a1372d829f..7889f7022e 100644 --- a/engines/sci/gui/gui_screen.cpp +++ b/engines/sci/gui/gui_screen.cpp @@ -33,25 +33,17 @@ namespace Sci { -SciGuiScreen::SciGuiScreen(OSystem *system, EngineState *state) - : _system(system), _s(state) { - init(); -} - -SciGuiScreen::~SciGuiScreen() { -} +SciGuiScreen::SciGuiScreen(OSystem *system, int16 width, int16 height, int16 scaleFactor) : + _system(system), _width(width), _height(height) { -void SciGuiScreen::init() { int i; uint16 base = 0; - _width = 320; - _height = 200; _pixels = _width * _height; // if you want to do scaling, adjust putPixel() accordingly - _displayWidth = 320; - _displayHeight = 200; + _displayWidth = _width * scaleFactor; + _displayHeight = _height * scaleFactor; _displayPixels = _displayWidth * _displayHeight; _visualScreen = initScreen(_pixels); @@ -65,6 +57,13 @@ void SciGuiScreen::init() { } } +SciGuiScreen::~SciGuiScreen() { + free(_visualScreen); + free(_priorityScreen); + free(_controlScreen); + free(_displayScreen); +} + byte *SciGuiScreen::initScreen(uint16 pixelCount) { byte *screen = (byte *)malloc(pixelCount); memset(screen, 0, pixelCount); diff --git a/engines/sci/gui/gui_screen.h b/engines/sci/gui/gui_screen.h index be7a35b6d0..87226bdb3c 100644 --- a/engines/sci/gui/gui_screen.h +++ b/engines/sci/gui/gui_screen.h @@ -26,7 +26,8 @@ #ifndef SCI_GUI_SCREEN_H #define SCI_GUI_SCREEN_H -#include "sci/gui/gui.h" +#include "sci/sci.h" +#include "sci/gui/gui_helpers.h" namespace Sci { @@ -40,10 +41,9 @@ namespace Sci { class SciGuiScreen { public: - SciGuiScreen(OSystem *system, EngineState *state); + SciGuiScreen(OSystem *system, int16 width = 320, int16 height = 200, int16 scaleFactor = 1); ~SciGuiScreen(); - void init(void); byte *initScreen(uint16 pixelCount); void copyToScreen(); @@ -75,11 +75,11 @@ private: void saveBitsScreen(Common::Rect rect, byte *screen, byte *&memoryPtr); OSystem *_system; - EngineState *_s; uint16 _baseTable[SCI_SCREEN_MAXHEIGHT]; uint16 _baseDisplayTable[SCI_SCREEN_MAXHEIGHT]; +public: // HACK. TODO: make private // these screens have the real resolution of the game engine (320x200 for SCI0/SCI1/SCI11 games, 640x480 for SCI2 games) // SCI0 games will be dithered in here at any time byte *_visualScreen; diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index 53ef01233d..1a05c9a20f 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -64,7 +64,7 @@ namespace Sci { -SciGui32::SciGui32(OSystem *system, EngineState *state) +SciGui32::SciGui32(OSystem *system, EngineState *state, SciGuiScreen *screen) : _system(system), s(state) { } diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index b57da26dd5..9861d3bcc5 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -32,7 +32,7 @@ namespace Sci { class SciGui32 : public SciGui { public: - SciGui32(OSystem *system, EngineState *s); + SciGui32(OSystem *system, EngineState *s, SciGuiScreen *screen); ~SciGui32(); // FIXME: Don't store EngineState diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index f43f763cc0..bd96f04978 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -155,9 +155,11 @@ Common::Error SciEngine::run() { GfxState gfx_state; _gamestate->gfx_state = &gfx_state; + SciGuiScreen *screen = new SciGuiScreen(_system); + // Gui change - //_gamestate->gui = new SciGui(_system, _gamestate); // new - _gamestate->gui = new SciGui32(_system, _gamestate); // old + //_gamestate->gui = new SciGui(_system, _gamestate, screen); // new + _gamestate->gui = new SciGui32(_system, _gamestate, screen); // old // Assign default values to the config manager, in case settings are missing ConfMan.registerDefault("dither_mode", "0"); @@ -178,7 +180,7 @@ Common::Error SciEngine::run() { // Default config ends #endif - gfxop_init(&gfx_state, &gfx_options, _resMan, 1, 1); + gfxop_init(&gfx_state, &gfx_options, _resMan, screen, 1); if (game_init_graphics(_gamestate)) { // Init interpreter graphics warning("Game initialization failed: Error in GFX subsystem. Aborting..."); @@ -200,6 +202,7 @@ Common::Error SciEngine::run() { script_free_engine(_gamestate); // Uninitialize game state script_free_breakpoints(_gamestate); + delete screen; delete _gamestate; gfxop_exit(&gfx_state); -- cgit v1.2.3