- 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
This commit is contained in:
parent
8e108cc0a0
commit
df29b0067e
17 changed files with 93 additions and 170 deletions
|
@ -30,50 +30,23 @@
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
#include "sci/sci.h"
|
#include "sci/sci.h"
|
||||||
|
#include "sci/gui/gui_screen.h"
|
||||||
#include "sci/gfx/gfx_driver.h"
|
#include "sci/gfx/gfx_driver.h"
|
||||||
#include "sci/gfx/gfx_tools.h"
|
#include "sci/gfx/gfx_tools.h"
|
||||||
|
|
||||||
|
#include "sci/gui/gui_screen.h"
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
GfxDriver::GfxDriver(int xfact, int yfact) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
_mode = gfx_new_mode(xfact, yfact, new Palette(256));
|
GfxDriver::GfxDriver(SciGuiScreen *screen, int scaleFactor) : _screen(screen) {
|
||||||
_mode->xsize = xfact * 320;
|
_mode = gfx_new_mode(scaleFactor, new Palette(256));
|
||||||
_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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_mode->palette)
|
if (_mode->palette)
|
||||||
_mode->palette->name = "global";
|
_mode->palette->name = "global";
|
||||||
}
|
}
|
||||||
|
|
||||||
GfxDriver::~GfxDriver() {
|
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) {
|
static void drawProc(int x, int y, int c, void *data) {
|
||||||
GfxDriver *drv = (GfxDriver *)data;
|
GfxDriver *drv = (GfxDriver *)data;
|
||||||
byte *p = drv->getVisual0();
|
byte *p = drv->_screen->_displayScreen;
|
||||||
uint8 col = c;
|
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,
|
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);
|
Graphics::drawLine(nstart.x, nstart.y, nend.x, nend.y, scolor, drawProc, this);
|
||||||
|
|
||||||
if (color.mask & GFX_MASK_PRIORITY) {
|
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) {
|
gfx_rectangle_fill_t shade_mode) {
|
||||||
if (color1.mask & GFX_MASK_VISUAL) {
|
if (color1.mask & GFX_MASK_VISUAL) {
|
||||||
for (int i = rect.y; i < rect.y + rect.height; i++) {
|
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);
|
color1.visual.getParentIndex(), rect.width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color1.mask & GFX_MASK_PRIORITY)
|
if (color1.mask & GFX_MASK_PRIORITY) {
|
||||||
gfx_draw_box_pixmap_i(_priority[0], rect, color1.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
|
// Pixmap operations
|
||||||
|
|
||||||
void 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;
|
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) {
|
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);
|
warning("Attempt to scale pixmap (%dx%d)->(%dx%d): Not supported\n", src.width, src.height, dest.width, dest.height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx_crossblit_pixmap(_mode, pxm, priority, src, dest, _visual[bufnr],
|
gfx_crossblit_pixmap(_mode, pxm, priority, src, dest, destBuffer,
|
||||||
_mode->xsize,
|
_mode->xsize,
|
||||||
_priority[bufnr]->index_data,
|
destPriority,
|
||||||
_priority[bufnr]->index_width, 1, 0);
|
_screen->_width, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) {
|
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;
|
pxm->height = src.height;
|
||||||
for (int i = 0; i < src.height; i++) {
|
for (int i = 0; i < src.height; i++) {
|
||||||
memcpy(pxm->data + i * src.width,
|
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);
|
src.width);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -174,28 +156,26 @@ void GfxDriver::grabPixmap(rect_t src, gfx_pixmap_t *pxm, gfx_map_mask_t map) {
|
||||||
// Buffer operations
|
// Buffer operations
|
||||||
|
|
||||||
void 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
|
|
||||||
|
|
||||||
/*
|
|
||||||
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) {
|
switch (buffer) {
|
||||||
case GFX_BUFFER_BACK:
|
case GFX_BUFFER_BACK:
|
||||||
for (int i = 0; i < src.height; i++) {
|
for (int i = 0; i < src.height; i++) {
|
||||||
memcpy(_visual[0] + ( (dest.y + i) * _mode->xsize + dest.x),
|
memcpy(_screen->_displayScreen + ( (dest.y + i) * _mode->xsize + dest.x),
|
||||||
_visual[1] + ( (src.y + i) * _mode->xsize + src.x), src.width );
|
_screen->_visualScreen + ( (src.y + i) * _mode->xsize + src.x), src.width );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((src.x == dest.x) && (src.y == dest.y))
|
if ((src.x == dest.x) && (src.y == dest.y)) {
|
||||||
gfx_copy_pixmap_box_i(_priority[0], _priority[1], src);
|
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;
|
break;
|
||||||
case GFX_BUFFER_FRONT: {
|
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();
|
g_system->updateScreen();
|
||||||
break;
|
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) {
|
void GfxDriver::setStaticBuffer(gfx_pixmap_t *pic, gfx_pixmap_t *priority) {
|
||||||
memcpy(_visual[1], pic->data, _mode->xsize * _mode->ysize);
|
memcpy(_screen->_visualScreen, pic->data, _mode->xsize * _mode->ysize);
|
||||||
gfx_copy_pixmap_box_i(_priority[1], priority, gfx_rect(0, 0, _mode->xsize, _mode->ysize));
|
memcpy(_screen->_controlScreen, priority->index_data, _mode->xsize * _mode->ysize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mouse pointer operations
|
// Mouse pointer operations
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
#include "sci/gfx/gfx_system.h"
|
#include "sci/gfx/gfx_system.h"
|
||||||
#include "sci/uinput.h"
|
#include "sci/uinput.h"
|
||||||
|
|
||||||
#include "graphics/pixelformat.h"
|
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
enum gfx_buffer_t {
|
enum gfx_buffer_t {
|
||||||
|
@ -85,7 +83,7 @@ public:
|
||||||
* not be set, or GFX_FATAL if the graphics target
|
* not be set, or GFX_FATAL if the graphics target
|
||||||
* is unuseable.
|
* is unuseable.
|
||||||
*/
|
*/
|
||||||
GfxDriver(int xfact, int yfact);
|
GfxDriver(SciGuiScreen *screen, int scaleFactor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uninitializes the current graphics mode.
|
* Uninitializes the current graphics mode.
|
||||||
|
@ -226,16 +224,15 @@ public:
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
gfx_mode_t *getMode() { return _mode; }
|
gfx_mode_t *getMode() { return _mode; }
|
||||||
byte *getVisual0() { return _visual[0]; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Animates palette
|
* Animates palette
|
||||||
*/
|
*/
|
||||||
void animatePalette(int fromColor, int toColor, int stepCount);
|
void animatePalette(int fromColor, int toColor, int stepCount);
|
||||||
|
|
||||||
|
public: // temporary hack
|
||||||
|
SciGuiScreen *_screen;
|
||||||
private:
|
private:
|
||||||
gfx_pixmap_t *_priority[2];
|
|
||||||
byte *_visual[2];
|
|
||||||
gfx_mode_t *_mode; /**< Currently active mode, NULL if no mode is active */
|
gfx_mode_t *_mode; /**< Currently active mode, NULL if no mode is active */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "sci/sci.h"
|
#include "sci/sci.h"
|
||||||
#include "sci/gfx/gfx_resource.h"
|
#include "sci/gfx/gfx_resource.h"
|
||||||
#include "sci/gfx/gfx_tools.h"
|
#include "sci/gfx/gfx_tools.h"
|
||||||
|
#include "sci/gui/gui_screen.h"
|
||||||
#include "sci/gfx/gfx_driver.h"
|
#include "sci/gfx/gfx_driver.h"
|
||||||
#include "sci/gfx/gfx_resmgr.h"
|
#include "sci/gfx/gfx_resmgr.h"
|
||||||
#include "sci/gfx/gfx_state_internal.h"
|
#include "sci/gfx/gfx_state_internal.h"
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#define SCI_GFX_GFX_RESOURCE_H
|
#define SCI_GFX_GFX_RESOURCE_H
|
||||||
|
|
||||||
#include "sci/gfx/gfx_system.h"
|
#include "sci/gfx/gfx_system.h"
|
||||||
|
#include "sci/gui/gui_screen.h"
|
||||||
#include "sci/gfx/gfx_driver.h"
|
#include "sci/gfx/gfx_driver.h"
|
||||||
|
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
|
|
|
@ -30,78 +30,19 @@
|
||||||
#include "sci/gfx/gfx_system.h"
|
#include "sci/gfx/gfx_system.h"
|
||||||
#include "sci/gfx/gfx_tools.h"
|
#include "sci/gfx/gfx_tools.h"
|
||||||
|
|
||||||
|
#include "graphics/primitives.h"
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
#define LINEMACRO(startx, starty, deltalinear, deltanonlinear, linearvar, nonlinearvar, \
|
static void drawProc(int x, int y, int c, void *data) {
|
||||||
linearend, nonlinearstart, linearmod, nonlinearmod) \
|
gfx_pixmap_t *pxm = (gfx_pixmap_t *)data;
|
||||||
incrNE = ((deltalinear) > 0) ? (deltalinear) : -(deltalinear); \
|
byte *p = pxm->index_data;
|
||||||
incrNE <<= 1; \
|
uint8 col = c;
|
||||||
deltanonlinear <<= 1; \
|
memcpy(p + (y * pxm->index_width + x), &col, 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 <int PIXELWIDTH>
|
|
||||||
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
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_draw_line_pixmap_i(gfx_pixmap_t *pxm, Common::Point start, Common::Point end, int color) {
|
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) {
|
void gfx_draw_box_buffer(byte *buffer, int linewidth, rect_t zone, int color) {
|
||||||
|
|
|
@ -43,11 +43,12 @@ void gfx_clip_box_basic(rect_t *box, int maxx, int maxy) {
|
||||||
box->height = maxy - box->y + 1;
|
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));
|
gfx_mode_t *mode = (gfx_mode_t *)malloc(sizeof(gfx_mode_t));
|
||||||
|
|
||||||
mode->scaleFactor = xfact;
|
mode->scaleFactor = scaleFactor;
|
||||||
mode->scaleFactor = yfact;
|
mode->xsize = scaleFactor * 320;
|
||||||
|
mode->ysize = scaleFactor * 200;
|
||||||
mode->palette = palette;
|
mode->palette = palette;
|
||||||
|
|
||||||
return mode;
|
return mode;
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "graphics/pixelformat.h"
|
#include "graphics/pixelformat.h"
|
||||||
|
|
||||||
#include "sci/gfx/gfx_system.h"
|
#include "sci/gfx/gfx_system.h"
|
||||||
|
#include "sci/gui/gui_screen.h"
|
||||||
#include "sci/gfx/gfx_driver.h"
|
#include "sci/gfx/gfx_driver.h"
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
@ -44,7 +45,7 @@ namespace Sci {
|
||||||
* @param[in] palette Number of palette colors, 0 if we're not in palette mode
|
* @param[in] palette Number of palette colors, 0 if we're not in palette mode
|
||||||
* @return A newly allocated gfx_mode_t structure
|
* @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
|
* 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_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
|
* Copies part of a pixmap to another pixmap, with clipping
|
||||||
*
|
*
|
||||||
|
|
|
@ -386,7 +386,7 @@ static void init_aux_pixmap(gfx_pixmap_t **pixmap) {
|
||||||
|
|
||||||
void gfxop_init(GfxState *state,
|
void gfxop_init(GfxState *state,
|
||||||
gfx_options_t *options, ResourceManager *resMan,
|
gfx_options_t *options, ResourceManager *resMan,
|
||||||
int xfact, int yfact) {
|
SciGuiScreen *screen, int scaleFactor) {
|
||||||
state->options = options;
|
state->options = options;
|
||||||
state->visible_map = GFX_MASK_VISUAL;
|
state->visible_map = GFX_MASK_VISUAL;
|
||||||
state->fullscreen_override = NULL; // No magical override
|
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->pic_port_bounds = gfx_rect(0, 10, 320, 190);
|
||||||
state->_dirtyRects.clear();
|
state->_dirtyRects.clear();
|
||||||
|
|
||||||
state->driver = new GfxDriver(xfact, yfact);
|
state->driver = new GfxDriver(screen, scaleFactor);
|
||||||
|
|
||||||
state->gfxResMan = new GfxResManager(state->options, state->driver, resMan);
|
state->gfxResMan = new GfxResManager(state->options, state->driver, resMan);
|
||||||
|
|
||||||
|
|
|
@ -136,15 +136,14 @@ struct GfxState {
|
||||||
* Initializes a graphics mode.
|
* Initializes a graphics mode.
|
||||||
*
|
*
|
||||||
* @param[in] state The state to initialize
|
* @param[in] state The state to initialize
|
||||||
* @param[in] xfact Horizontal scale factor
|
* @param[in] scaleFactor Scale factor
|
||||||
* @param[in] yfact Vertical scale factors
|
|
||||||
* @param[in] mode Graphics mode to use
|
* @param[in] mode Graphics mode to use
|
||||||
* @param[in] options Rendering options
|
* @param[in] options Rendering options
|
||||||
* @param[in] resMan Resource manager to use
|
* @param[in] resMan Resource manager to use
|
||||||
*/
|
*/
|
||||||
void gfxop_init(GfxState *state,
|
void gfxop_init(GfxState *state,
|
||||||
gfx_options_t *options, ResourceManager *resMan,
|
gfx_options_t *options, ResourceManager *resMan,
|
||||||
int xfact = 1, int yfact = 1);
|
SciGuiScreen *screen, int scaleFactor = 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deinitializes a currently active driver.
|
* Deinitializes a currently active driver.
|
||||||
|
|
|
@ -1485,8 +1485,7 @@ void gfxr_draw_pic01(gfxr_pic_t *pic, int flags, int default_palette, int size,
|
||||||
view->index_height = CLIP<int>(view->index_height, 0, portBounds.height());
|
view->index_height = CLIP<int>(view->index_height, 0, portBounds.height());
|
||||||
|
|
||||||
// Set up mode structure for resizing the view
|
// Set up mode structure for resizing the view
|
||||||
gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320,
|
gfx_mode_t *mode = gfx_new_mode(pic->visual_map->index_width / 320, view->palette);
|
||||||
pic->visual_map->index_height / 200, view->palette);
|
|
||||||
|
|
||||||
gfx_xlate_pixmap(view, mode);
|
gfx_xlate_pixmap(view, mode);
|
||||||
gfx_free_mode(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();
|
view->palette = pic->visual_map->palette->getref();
|
||||||
|
|
||||||
// Set up mode structure for resizing the view
|
// 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_xlate_pixmap(view, mode);
|
||||||
gfx_free_mode(mode);
|
gfx_free_mode(mode);
|
||||||
|
|
|
@ -38,9 +38,8 @@
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
SciGui::SciGui(OSystem *system, EngineState *state)
|
SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen)
|
||||||
: _system(system), _s(state) {
|
: _system(system), _s(state), _screen(screen) {
|
||||||
_screen = new SciGuiScreen(_system, _s);
|
|
||||||
_gfx = new SciGuiGfx(_system, _s, _screen);
|
_gfx = new SciGuiGfx(_system, _s, _screen);
|
||||||
_windowMgr = new SciGuiWindowMgr(_s, _gfx);
|
_windowMgr = new SciGuiWindowMgr(_s, _gfx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class SciGuiresources;
|
||||||
class SciGuiWindowMgr;
|
class SciGuiWindowMgr;
|
||||||
class SciGui {
|
class SciGui {
|
||||||
public:
|
public:
|
||||||
SciGui(OSystem *system, EngineState *s);
|
SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen);
|
||||||
SciGui();
|
SciGui();
|
||||||
virtual ~SciGui();
|
virtual ~SciGui();
|
||||||
|
|
||||||
|
|
|
@ -33,25 +33,17 @@
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
SciGuiScreen::SciGuiScreen(OSystem *system, EngineState *state)
|
SciGuiScreen::SciGuiScreen(OSystem *system, int16 width, int16 height, int16 scaleFactor) :
|
||||||
: _system(system), _s(state) {
|
_system(system), _width(width), _height(height) {
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
SciGuiScreen::~SciGuiScreen() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void SciGuiScreen::init() {
|
|
||||||
int i;
|
int i;
|
||||||
uint16 base = 0;
|
uint16 base = 0;
|
||||||
|
|
||||||
_width = 320;
|
|
||||||
_height = 200;
|
|
||||||
_pixels = _width * _height;
|
_pixels = _width * _height;
|
||||||
|
|
||||||
// if you want to do scaling, adjust putPixel() accordingly
|
// if you want to do scaling, adjust putPixel() accordingly
|
||||||
_displayWidth = 320;
|
_displayWidth = _width * scaleFactor;
|
||||||
_displayHeight = 200;
|
_displayHeight = _height * scaleFactor;
|
||||||
_displayPixels = _displayWidth * _displayHeight;
|
_displayPixels = _displayWidth * _displayHeight;
|
||||||
|
|
||||||
_visualScreen = initScreen(_pixels);
|
_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 *SciGuiScreen::initScreen(uint16 pixelCount) {
|
||||||
byte *screen = (byte *)malloc(pixelCount);
|
byte *screen = (byte *)malloc(pixelCount);
|
||||||
memset(screen, 0, pixelCount);
|
memset(screen, 0, pixelCount);
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
#ifndef SCI_GUI_SCREEN_H
|
#ifndef SCI_GUI_SCREEN_H
|
||||||
#define 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 {
|
namespace Sci {
|
||||||
|
|
||||||
|
@ -40,10 +41,9 @@ namespace Sci {
|
||||||
|
|
||||||
class SciGuiScreen {
|
class SciGuiScreen {
|
||||||
public:
|
public:
|
||||||
SciGuiScreen(OSystem *system, EngineState *state);
|
SciGuiScreen(OSystem *system, int16 width = 320, int16 height = 200, int16 scaleFactor = 1);
|
||||||
~SciGuiScreen();
|
~SciGuiScreen();
|
||||||
|
|
||||||
void init(void);
|
|
||||||
byte *initScreen(uint16 pixelCount);
|
byte *initScreen(uint16 pixelCount);
|
||||||
|
|
||||||
void copyToScreen();
|
void copyToScreen();
|
||||||
|
@ -75,11 +75,11 @@ private:
|
||||||
void saveBitsScreen(Common::Rect rect, byte *screen, byte *&memoryPtr);
|
void saveBitsScreen(Common::Rect rect, byte *screen, byte *&memoryPtr);
|
||||||
|
|
||||||
OSystem *_system;
|
OSystem *_system;
|
||||||
EngineState *_s;
|
|
||||||
|
|
||||||
uint16 _baseTable[SCI_SCREEN_MAXHEIGHT];
|
uint16 _baseTable[SCI_SCREEN_MAXHEIGHT];
|
||||||
uint16 _baseDisplayTable[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)
|
// 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
|
// SCI0 games will be dithered in here at any time
|
||||||
byte *_visualScreen;
|
byte *_visualScreen;
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
namespace Sci {
|
namespace Sci {
|
||||||
|
|
||||||
SciGui32::SciGui32(OSystem *system, EngineState *state)
|
SciGui32::SciGui32(OSystem *system, EngineState *state, SciGuiScreen *screen)
|
||||||
: _system(system), s(state) {
|
: _system(system), s(state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Sci {
|
||||||
|
|
||||||
class SciGui32 : public SciGui {
|
class SciGui32 : public SciGui {
|
||||||
public:
|
public:
|
||||||
SciGui32(OSystem *system, EngineState *s);
|
SciGui32(OSystem *system, EngineState *s, SciGuiScreen *screen);
|
||||||
~SciGui32();
|
~SciGui32();
|
||||||
|
|
||||||
// FIXME: Don't store EngineState
|
// FIXME: Don't store EngineState
|
||||||
|
|
|
@ -155,9 +155,11 @@ Common::Error SciEngine::run() {
|
||||||
GfxState gfx_state;
|
GfxState gfx_state;
|
||||||
_gamestate->gfx_state = &gfx_state;
|
_gamestate->gfx_state = &gfx_state;
|
||||||
|
|
||||||
|
SciGuiScreen *screen = new SciGuiScreen(_system);
|
||||||
|
|
||||||
// Gui change
|
// Gui change
|
||||||
//_gamestate->gui = new SciGui(_system, _gamestate); // new
|
//_gamestate->gui = new SciGui(_system, _gamestate, screen); // new
|
||||||
_gamestate->gui = new SciGui32(_system, _gamestate); // old
|
_gamestate->gui = new SciGui32(_system, _gamestate, screen); // old
|
||||||
|
|
||||||
// Assign default values to the config manager, in case settings are missing
|
// Assign default values to the config manager, in case settings are missing
|
||||||
ConfMan.registerDefault("dither_mode", "0");
|
ConfMan.registerDefault("dither_mode", "0");
|
||||||
|
@ -178,7 +180,7 @@ Common::Error SciEngine::run() {
|
||||||
// Default config ends
|
// Default config ends
|
||||||
#endif
|
#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
|
if (game_init_graphics(_gamestate)) { // Init interpreter graphics
|
||||||
warning("Game initialization failed: Error in GFX subsystem. Aborting...");
|
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_engine(_gamestate); // Uninitialize game state
|
||||||
script_free_breakpoints(_gamestate);
|
script_free_breakpoints(_gamestate);
|
||||||
|
|
||||||
|
delete screen;
|
||||||
delete _gamestate;
|
delete _gamestate;
|
||||||
|
|
||||||
gfxop_exit(&gfx_state);
|
gfxop_exit(&gfx_state);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue