2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2005-04-05 18:08:02 +00:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2005-04-09 19:19:54 +00:00
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-04-05 18:08:02 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2006-03-29 15:59:37 +00:00
|
|
|
#include "common/endian.h"
|
2010-05-04 11:58:12 +00:00
|
|
|
|
|
|
|
#include "engines/util.h"
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "graphics/cursorman.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "graphics/palette.h"
|
2008-12-12 02:44:34 +00:00
|
|
|
#include "graphics/surface.h"
|
2006-03-29 15:59:37 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/gob.h"
|
|
|
|
#include "gob/video.h"
|
2007-03-20 14:51:57 +00:00
|
|
|
#include "gob/global.h"
|
|
|
|
#include "gob/util.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
#include "gob/dataio.h"
|
2006-05-01 12:43:50 +00:00
|
|
|
#include "gob/draw.h"
|
2005-04-05 15:07:40 +00:00
|
|
|
|
|
|
|
namespace Gob {
|
|
|
|
|
2009-07-09 02:54:10 +00:00
|
|
|
Font::Font(const byte *data) : _dataPtr(data) {
|
|
|
|
assert(data);
|
|
|
|
|
|
|
|
bool hasWidths = _dataPtr[0] & 0x80;
|
|
|
|
|
|
|
|
_data = _dataPtr + 4;
|
|
|
|
_itemWidth = _dataPtr[0] & 0x7F;
|
|
|
|
_itemHeight = _dataPtr[1];
|
|
|
|
_startItem = _dataPtr[2];
|
|
|
|
_endItem = _dataPtr[3];
|
|
|
|
_charWidths = 0;
|
|
|
|
|
|
|
|
uint8 rowAlignedBits = (_itemWidth - 1) / 8 + 1;
|
|
|
|
|
|
|
|
_itemSize = rowAlignedBits * _itemHeight;
|
|
|
|
_bitWidth = _itemWidth;
|
|
|
|
|
|
|
|
if (hasWidths)
|
|
|
|
_charWidths = _dataPtr + 4 + _itemSize * getCharCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
Font::~Font() {
|
2009-07-10 21:49:47 +00:00
|
|
|
delete[] _dataPtr;
|
2009-07-09 02:54:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Font::getCharWidth(uint8 c) const {
|
|
|
|
if (!_charWidths || (_endItem == 0))
|
|
|
|
return _itemWidth;
|
|
|
|
|
|
|
|
if ((c < _startItem) || (c > _endItem))
|
|
|
|
return _itemWidth;
|
|
|
|
|
|
|
|
return _charWidths[c - _startItem];
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Font::getCharWidth() const {
|
|
|
|
return _itemWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8 Font::getCharHeight() const {
|
|
|
|
return _itemHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 Font::getCharCount() const {
|
|
|
|
return _endItem - _startItem + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Font::isMonospaced() const {
|
|
|
|
return _charWidths == 0;
|
|
|
|
}
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
void Font::drawLetter(Surface &surf, uint8 c, uint16 x, uint16 y,
|
|
|
|
uint32 color1, uint32 color2, bool transp) const {
|
|
|
|
|
|
|
|
uint16 data;
|
|
|
|
|
|
|
|
const byte *src = getCharData(c);
|
|
|
|
if (!src) {
|
|
|
|
warning("Font::drawLetter(): getCharData() == 0");
|
|
|
|
return;
|
2009-07-09 02:54:10 +00:00
|
|
|
}
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
Pixel dst = surf.get(x, y);
|
2009-07-09 02:54:10 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
int nWidth = _itemWidth;
|
|
|
|
if (nWidth & 7)
|
|
|
|
nWidth = (nWidth & 0xF8) + 8;
|
2009-07-09 02:54:10 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
nWidth >>= 3;
|
2009-07-09 02:54:10 +00:00
|
|
|
|
2011-01-27 20:50:43 +00:00
|
|
|
for (int i = 0; (i < _itemHeight) && dst.isValid(); i++) {
|
2010-09-30 13:02:16 +00:00
|
|
|
int width = _itemWidth;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
for (int k = 0; k < nWidth; k++) {
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
data = *src++;
|
|
|
|
for (int j = 0; j < MIN(8, width); j++) {
|
2011-01-27 20:50:43 +00:00
|
|
|
|
|
|
|
if (dst.isValid()) {
|
|
|
|
if (data & 0x80)
|
|
|
|
dst.set(color1);
|
|
|
|
else if (!transp)
|
|
|
|
dst.set(color2);
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
dst++;
|
|
|
|
data <<= 1;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
width -= 8;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
dst += surf.getWidth() - _itemWidth;
|
|
|
|
}
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
|
2012-06-29 23:46:24 +00:00
|
|
|
void Font::drawString(const Common::String &str, int16 x, int16 y, int16 color1, int16 color2,
|
|
|
|
bool transp, Surface &dest) const {
|
|
|
|
|
|
|
|
const char *s = str.c_str();
|
|
|
|
|
|
|
|
while (*s != '\0') {
|
|
|
|
const int16 charRight = x + getCharWidth(*s);
|
|
|
|
const int16 charBottom = y + getCharHeight();
|
|
|
|
|
|
|
|
if ((x >= 0) && (y >= 0) && (charRight <= dest.getWidth()) && (charBottom <= dest.getHeight()))
|
|
|
|
drawLetter(dest, *s, x, y, color1, color2, transp);
|
|
|
|
|
|
|
|
x += getCharWidth(*s);
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
const byte *Font::getCharData(uint8 c) const {
|
|
|
|
if (_endItem == 0) {
|
|
|
|
warning("Font::getCharData(): _endItem == 0");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((c < _startItem) || (c > _endItem))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return _data + (c - _startItem) * _itemSize;
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
Video::Video(GobEngine *vm) : _vm(vm) {
|
2007-03-20 14:51:57 +00:00
|
|
|
_doRangeClamp = false;
|
2008-05-17 23:55:04 +00:00
|
|
|
|
2007-01-29 17:04:37 +00:00
|
|
|
_surfWidth = 320;
|
2007-02-06 14:42:05 +00:00
|
|
|
_surfHeight = 200;
|
2008-05-17 23:55:04 +00:00
|
|
|
|
2007-02-06 14:42:05 +00:00
|
|
|
_scrollOffsetX = 0;
|
|
|
|
_scrollOffsetY = 0;
|
2008-05-17 23:55:04 +00:00
|
|
|
|
2007-04-19 13:51:57 +00:00
|
|
|
_splitHeight1 = 200;
|
|
|
|
_splitHeight2 = 0;
|
|
|
|
_splitStart = 0;
|
2007-04-06 13:30:09 +00:00
|
|
|
|
2008-05-03 20:08:46 +00:00
|
|
|
_screenDeltaX = 0;
|
|
|
|
_screenDeltaY = 0;
|
|
|
|
|
2007-04-06 13:30:09 +00:00
|
|
|
_curSparse = 0;
|
|
|
|
_lastSparse = 0xFFFFFFFF;
|
2008-12-04 18:38:55 +00:00
|
|
|
|
|
|
|
_dirtyAll = false;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2008-12-14 04:33:28 +00:00
|
|
|
Video::~Video() {
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Video::initPrimary(int16 mode) {
|
|
|
|
if ((mode != 3) && (mode != -1))
|
|
|
|
_vm->validateVideoMode(mode);
|
|
|
|
_vm->validateVideoMode(_vm->_global->_videoMode);
|
|
|
|
|
|
|
|
if (mode == -1)
|
|
|
|
mode = 3;
|
|
|
|
_vm->_global->_oldMode = mode;
|
|
|
|
|
|
|
|
if (mode != 3) {
|
2011-02-02 16:48:04 +00:00
|
|
|
initSurfDesc(_surfWidth, _surfHeight, PRIMARY_SURFACE);
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (!_vm->_global->_dontSetPalette)
|
|
|
|
Video::setFullPalette(_vm->_global->_pPaletteDesc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-02 16:48:04 +00:00
|
|
|
SurfacePtr Video::initSurfDesc(int16 width, int16 height, int16 flags) {
|
2010-09-30 13:02:16 +00:00
|
|
|
SurfacePtr descPtr;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
|
|
|
if (flags & PRIMARY_SURFACE)
|
|
|
|
assert((width == _surfWidth) && (height == _surfHeight));
|
|
|
|
|
|
|
|
if (flags & PRIMARY_SURFACE) {
|
|
|
|
_vm->_global->_primaryWidth = width;
|
|
|
|
_vm->_global->_primaryHeight = height;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
descPtr = _vm->_global->_primarySurfDesc;
|
|
|
|
descPtr->resize(width, height);
|
|
|
|
} else {
|
|
|
|
assert(!(flags & DISABLE_SPR_ALLOC));
|
|
|
|
|
|
|
|
if (!(flags & SCUMMVM_CURSOR))
|
|
|
|
width = (width + 7) & 0xFFF8;
|
|
|
|
|
2010-09-30 13:03:22 +00:00
|
|
|
descPtr = SurfacePtr(new Surface(width, height, _vm->getPixelFormat().bytesPerPixel));
|
2007-03-20 14:51:57 +00:00
|
|
|
}
|
|
|
|
return descPtr;
|
|
|
|
}
|
|
|
|
|
2008-05-03 20:08:46 +00:00
|
|
|
void Video::clearScreen() {
|
2009-02-15 21:20:21 +00:00
|
|
|
g_system->fillScreen(0);
|
2008-05-03 20:08:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Video::setSize(bool defaultTo1XScaler) {
|
2010-09-30 12:59:48 +00:00
|
|
|
if (_vm->isTrueColor())
|
|
|
|
initGraphics(_vm->_width, _vm->_height, defaultTo1XScaler, 0);
|
|
|
|
else
|
|
|
|
initGraphics(_vm->_width, _vm->_height, defaultTo1XScaler);
|
2008-05-03 20:08:46 +00:00
|
|
|
}
|
|
|
|
|
2007-03-29 17:55:39 +00:00
|
|
|
void Video::retrace(bool mouse) {
|
2007-03-20 14:51:57 +00:00
|
|
|
if (mouse)
|
2012-05-29 12:16:31 +00:00
|
|
|
CursorMan.showMouse((_vm->_draw->_showCursor & 2) != 0);
|
2011-01-26 19:04:24 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
if (_vm->_global->_primarySurfDesc) {
|
2008-05-03 20:08:46 +00:00
|
|
|
int screenX = _screenDeltaX;
|
|
|
|
int screenY = _screenDeltaY;
|
2008-05-26 22:02:20 +00:00
|
|
|
int screenWidth = MIN<int>(_surfWidth - _scrollOffsetX, _vm->_width);
|
2009-10-28 14:57:13 +00:00
|
|
|
int screenHeight = MIN<int>(_surfHeight - _splitHeight2 - _scrollOffsetY, _vm->_height - _splitHeight2);
|
2008-05-03 20:08:46 +00:00
|
|
|
|
2008-12-04 18:38:55 +00:00
|
|
|
dirtyRectsApply(_scrollOffsetX, _scrollOffsetY, screenWidth, screenHeight,
|
|
|
|
screenX, screenY);
|
2008-05-03 20:08:46 +00:00
|
|
|
|
2008-05-17 23:55:04 +00:00
|
|
|
if (_splitSurf) {
|
|
|
|
|
|
|
|
screenX = 0;
|
|
|
|
screenY = _vm->_height - _splitSurf->getHeight();
|
|
|
|
screenWidth = MIN<int>(_vm->_width, _splitSurf->getWidth());
|
|
|
|
screenHeight = _splitSurf->getHeight();
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
_splitSurf->blitToScreen(0, 0, screenWidth - 1, screenHeight - 1, screenX, screenY);
|
2008-05-17 23:55:04 +00:00
|
|
|
|
|
|
|
} else if (_splitHeight2 > 0) {
|
|
|
|
|
2008-05-03 20:08:46 +00:00
|
|
|
screenX = 0;
|
|
|
|
screenY = _vm->_height - _splitHeight2;
|
2008-05-13 18:43:26 +00:00
|
|
|
screenWidth = MIN<int>(_surfWidth, _vm->_width);
|
2008-05-03 20:08:46 +00:00
|
|
|
screenHeight = _splitHeight2;
|
|
|
|
|
2008-12-04 18:38:55 +00:00
|
|
|
dirtyRectsApply(0, _splitStart, screenWidth, screenHeight, screenX, screenY);
|
2008-05-03 20:08:46 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 18:38:55 +00:00
|
|
|
dirtyRectsClear();
|
2007-03-20 14:51:57 +00:00
|
|
|
g_system->updateScreen();
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2008-12-04 18:38:55 +00:00
|
|
|
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2007-03-29 17:55:39 +00:00
|
|
|
void Video::waitRetrace(bool mouse) {
|
2007-08-19 17:26:06 +00:00
|
|
|
uint32 time = _vm->_util->getTimeKey();
|
2007-03-29 17:55:39 +00:00
|
|
|
retrace(mouse);
|
2007-08-19 17:26:06 +00:00
|
|
|
_vm->_util->delay(MAX(1, 10 - (int)(_vm->_util->getTimeKey() - time)));
|
2007-03-29 17:55:39 +00:00
|
|
|
}
|
|
|
|
|
2007-04-06 13:30:09 +00:00
|
|
|
void Video::sparseRetrace(int max) {
|
|
|
|
uint32 timeKey = _vm->_util->getTimeKey();
|
|
|
|
|
|
|
|
if ((_curSparse++ > max) || ((timeKey - _lastSparse) > 1000)) {
|
|
|
|
_curSparse = 0;
|
|
|
|
retrace(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
_lastSparse = timeKey;
|
|
|
|
}
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
void Video::drawPacked(byte *sprBuf, int16 width, int16 height,
|
|
|
|
int16 x, int16 y, byte transp, Surface &dest) {
|
2006-05-31 08:44:14 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
int destRight = x + width;
|
|
|
|
int destBottom = y + height;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
Pixel dst = dest.get(x, y);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
int curx = x;
|
|
|
|
int cury = y;
|
2007-03-20 14:51:57 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
while (1) {
|
|
|
|
uint8 val = *sprBuf++;
|
|
|
|
unsigned int repeat = val & 7;
|
|
|
|
val &= 0xF8;
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
if (!(val & 8)) {
|
|
|
|
repeat <<= 8;
|
|
|
|
repeat |= *sprBuf++;
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
2010-09-30 13:02:16 +00:00
|
|
|
repeat++;
|
|
|
|
val >>= 4;
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < repeat; ++i) {
|
|
|
|
if (curx < dest.getWidth() && cury < dest.getHeight())
|
|
|
|
if (!transp || val)
|
|
|
|
dst.set(val);
|
|
|
|
|
|
|
|
dst++;
|
|
|
|
curx++;
|
|
|
|
if (curx == destRight) {
|
|
|
|
dst += dest.getWidth() + x - curx;
|
|
|
|
curx = x;
|
|
|
|
cury++;
|
|
|
|
if (cury == destBottom)
|
|
|
|
return;
|
|
|
|
}
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2006-04-18 09:59:18 +00:00
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Video::drawPackedSprite(byte *sprBuf, int16 width, int16 height,
|
2010-09-30 13:02:16 +00:00
|
|
|
int16 x, int16 y, int16 transp, Surface &dest) {
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2006-05-11 19:43:30 +00:00
|
|
|
if (spriteUncompressor(sprBuf, width, height, x, y, transp, dest))
|
2005-04-05 15:07:40 +00:00
|
|
|
return;
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
drawPacked(sprBuf, width, height, x, y, transp, dest);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
void Video::drawPackedSprite(const char *path, Surface &dest, int width) {
|
2010-10-31 20:07:14 +00:00
|
|
|
int32 size;
|
|
|
|
byte *data = _vm->_dataIO->getFile(path, size);
|
2012-06-27 23:31:59 +00:00
|
|
|
if (!data) {
|
|
|
|
warning("Video::drawPackedSprite(): Failed to open sprite \"%s\"", path);
|
|
|
|
return;
|
|
|
|
}
|
2007-02-04 15:45:15 +00:00
|
|
|
|
2009-06-06 20:03:13 +00:00
|
|
|
drawPackedSprite(data, width, dest.getHeight(), 0, 0, 0, dest);
|
2007-02-04 15:45:15 +00:00
|
|
|
delete[] data;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
void Video::setPalElem(int16 index, char red, char green, char blue,
|
|
|
|
int16 unused, int16 vidMode) {
|
2011-02-13 14:36:11 +00:00
|
|
|
byte pal[3];
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->validateVideoMode(vidMode);
|
|
|
|
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_global->_redPalette[index] = red;
|
|
|
|
_vm->_global->_greenPalette[index] = green;
|
|
|
|
_vm->_global->_bluePalette[index] = blue;
|
2007-03-20 14:51:57 +00:00
|
|
|
setPalColor(pal, red, green, blue);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2010-09-30 13:00:30 +00:00
|
|
|
if (_vm->getPixelFormat().bytesPerPixel == 1)
|
2011-02-07 17:52:38 +00:00
|
|
|
g_system->getPaletteManager()->setPalette(pal, index, 1);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Video::setPalette(PalDesc *palDesc) {
|
2011-02-13 14:36:11 +00:00
|
|
|
byte pal[768];
|
2005-04-05 15:07:40 +00:00
|
|
|
int16 numcolors;
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
_vm->validateVideoMode(_vm->_global->_videoMode);
|
2005-04-05 15:07:40 +00:00
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
numcolors = _vm->_global->_setAllPalette ? 256 : 16;
|
|
|
|
for (int i = 0; i < numcolors; i++)
|
2011-02-13 14:36:11 +00:00
|
|
|
setPalColor(pal + i * 3, palDesc->vgaPal[i]);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2010-09-30 13:00:30 +00:00
|
|
|
if (_vm->getPixelFormat().bytesPerPixel == 1)
|
2011-02-07 17:52:38 +00:00
|
|
|
g_system->getPaletteManager()->setPalette(pal, 0, numcolors);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2006-01-03 23:14:39 +00:00
|
|
|
void Video::setFullPalette(PalDesc *palDesc) {
|
2006-01-04 01:48:15 +00:00
|
|
|
if (_vm->_global->_setAllPalette) {
|
2011-02-13 14:36:11 +00:00
|
|
|
byte pal[768];
|
2007-03-20 14:51:57 +00:00
|
|
|
Color *colors = palDesc->vgaPal;
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++) {
|
2006-01-04 01:48:15 +00:00
|
|
|
_vm->_global->_redPalette[i] = colors[i].red;
|
|
|
|
_vm->_global->_greenPalette[i] = colors[i].green;
|
|
|
|
_vm->_global->_bluePalette[i] = colors[i].blue;
|
2011-02-13 14:36:11 +00:00
|
|
|
setPalColor(pal + i * 3, colors[i]);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2010-09-30 13:00:30 +00:00
|
|
|
if (_vm->getPixelFormat().bytesPerPixel == 1)
|
2011-02-07 17:52:38 +00:00
|
|
|
g_system->getPaletteManager()->setPalette(pal, 0, 256);
|
2007-03-20 14:51:57 +00:00
|
|
|
} else
|
2006-01-03 23:14:39 +00:00
|
|
|
Video::setPalette(palDesc);
|
2005-04-05 15:07:40 +00:00
|
|
|
}
|
|
|
|
|
2007-03-29 17:55:39 +00:00
|
|
|
void Video::setPalette(Color *palette) {
|
|
|
|
Color *palBak;
|
|
|
|
bool setAllPalBak;
|
|
|
|
|
|
|
|
palBak = _vm->_global->_pPaletteDesc->vgaPal;
|
|
|
|
setAllPalBak = _vm->_global->_setAllPalette;
|
|
|
|
|
|
|
|
_vm->_global->_pPaletteDesc->vgaPal = palette;
|
|
|
|
_vm->_global->_setAllPalette = true;
|
|
|
|
setFullPalette(_vm->_global->_pPaletteDesc);
|
|
|
|
|
|
|
|
_vm->_global->_setAllPalette = setAllPalBak;
|
|
|
|
_vm->_global->_pPaletteDesc->vgaPal = palBak;
|
|
|
|
}
|
|
|
|
|
2008-12-04 18:38:55 +00:00
|
|
|
void Video::dirtyRectsClear() {
|
|
|
|
_dirtyRects.clear();
|
|
|
|
_dirtyAll = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Video::dirtyRectsAll() {
|
|
|
|
_dirtyRects.clear();
|
|
|
|
_dirtyAll = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Video::dirtyRectsAdd(int16 left, int16 top, int16 right, int16 bottom) {
|
|
|
|
if (_dirtyAll)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_dirtyRects.push_back(Common::Rect(left, top, right + 1, bottom + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Video::dirtyRectsApply(int left, int top, int width, int height, int x, int y) {
|
|
|
|
if (_dirtyAll) {
|
2010-09-30 13:02:16 +00:00
|
|
|
_vm->_global->_primarySurfDesc->blitToScreen(left, top, left + width - 1, top + height - 1, x, y);
|
2008-12-04 18:38:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
int right = left + width;
|
|
|
|
int bottom = top + height;
|
2008-12-04 18:38:55 +00:00
|
|
|
|
|
|
|
Common::List<Common::Rect>::const_iterator it;
|
|
|
|
for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) {
|
2010-09-30 13:02:16 +00:00
|
|
|
int l = MAX<int>(left , it->left);
|
|
|
|
int t = MAX<int>(top , it->top);
|
|
|
|
int r = MIN<int>(right , it->right);
|
2008-12-04 18:38:55 +00:00
|
|
|
int b = MIN<int>(bottom, it->bottom);
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
if ((r <= l) || (b <= t))
|
2008-12-04 18:38:55 +00:00
|
|
|
continue;
|
|
|
|
|
2010-09-30 13:02:16 +00:00
|
|
|
_vm->_global->_primarySurfDesc->blitToScreen(l, t, r - 1, b - 1, x + (l - left), y + (t - top));
|
2008-12-04 18:38:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:51:57 +00:00
|
|
|
} // End of namespace Gob
|