mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-09 18:21:38 +00:00
ACCESS: Changed engine to use Graphics::ManagedSurface
This commit is contained in:
parent
433a2daa6a
commit
9c7569b74b
@ -436,20 +436,9 @@ void AccessEngine::copyBF1BF2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AccessEngine::copyBF2Vid() {
|
void AccessEngine::copyBF2Vid() {
|
||||||
const byte *srcP = (const byte *)_buffer2.getPixels();
|
_screen->blitFrom(_buffer2,
|
||||||
byte *destP = (byte *)_screen->getBasePtr(_screen->_windowXAdd,
|
Common::Rect(0, 0, _screen->_vWindowBytesWide, _screen->_vWindowLinesTall),
|
||||||
_screen->_windowYAdd + _screen->_screenYOff);
|
Common::Point(_screen->_windowXAdd, _screen->_windowYAdd));
|
||||||
|
|
||||||
for (int yp = 0; yp < _screen->_vWindowLinesTall; ++yp) {
|
|
||||||
Common::copy(srcP, srcP + _screen->_vWindowBytesWide, destP);
|
|
||||||
srcP += _buffer2.pitch;
|
|
||||||
destP += _screen->pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add dirty rect for affected area
|
|
||||||
Common::Rect r(_screen->_vWindowBytesWide, _screen->_vWindowLinesTall);
|
|
||||||
r.moveTo(_screen->_windowXAdd, _screen->_windowYAdd + _screen->_screenYOff);
|
|
||||||
_screen->addDirtyRect(r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
|
void AccessEngine::playVideo(int videoNum, const Common::Point &pt) {
|
||||||
|
@ -110,7 +110,7 @@ void ImageEntryList::addToList(ImageEntry &ie) {
|
|||||||
int ASurface::_clipWidth;
|
int ASurface::_clipWidth;
|
||||||
int ASurface::_clipHeight;
|
int ASurface::_clipHeight;
|
||||||
|
|
||||||
ASurface::ASurface(): Graphics::Surface() {
|
ASurface::ASurface(): Graphics::ManagedSurface() {
|
||||||
_leftSkip = _rightSkip = 0;
|
_leftSkip = _rightSkip = 0;
|
||||||
_topSkip = _bottomSkip = 0;
|
_topSkip = _bottomSkip = 0;
|
||||||
_lastBoundsX = _lastBoundsY = 0;
|
_lastBoundsX = _lastBoundsY = 0;
|
||||||
@ -122,19 +122,129 @@ ASurface::ASurface(): Graphics::Surface() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASurface::~ASurface() {
|
ASurface::~ASurface() {
|
||||||
free();
|
|
||||||
_savedBlock.free();
|
_savedBlock.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASurface::create(uint16 width, uint16 height) {
|
|
||||||
Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::clearBuffer() {
|
void ASurface::clearBuffer() {
|
||||||
byte *pSrc = (byte *)getPixels();
|
byte *pSrc = (byte *)getPixels();
|
||||||
Common::fill(pSrc, pSrc + w * h, 0);
|
Common::fill(pSrc, pSrc + w * h, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt) {
|
||||||
|
SpriteFrame *frame = sprite->getFrame(frameNum);
|
||||||
|
Common::Rect r(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h);
|
||||||
|
|
||||||
|
if (!clip(r)) {
|
||||||
|
_lastBoundsX = r.left;
|
||||||
|
_lastBoundsY = r.top;
|
||||||
|
_lastBoundsW = r.width();
|
||||||
|
_lastBoundsH = r.height();
|
||||||
|
|
||||||
|
plotF(frame, pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::copyBuffer(Graphics::ManagedSurface *src) {
|
||||||
|
blitFrom(*src);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
|
||||||
|
sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
|
||||||
|
sPlotB(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
|
||||||
|
transBlitFrom(*frame, Common::Rect(0, 0, frame->w, frame->h), bounds, TRANSPARENCY, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
|
||||||
|
transBlitFrom(*frame, Common::Rect(0, 0, frame->w, frame->h), bounds, TRANSPARENCY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
|
||||||
|
copyRectToSurface(*src, bounds.left, bounds.top, bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::copyTo(ASurface *dest) {
|
||||||
|
if (dest->empty())
|
||||||
|
dest->create(this->w, this->h);
|
||||||
|
|
||||||
|
dest->blitFrom(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::saveBlock(const Common::Rect &bounds) {
|
||||||
|
_savedBounds = bounds;
|
||||||
|
_savedBounds.clip(Common::Rect(0, 0, this->w, this->h));
|
||||||
|
|
||||||
|
_savedBlock.free();
|
||||||
|
_savedBlock.create(bounds.width(), bounds.height(),
|
||||||
|
Graphics::PixelFormat::createFormatCLUT8());
|
||||||
|
_savedBlock.copyRectToSurface(*this, 0, 0, _savedBounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::restoreBlock() {
|
||||||
|
if (!_savedBounds.isEmpty()) {
|
||||||
|
copyRectToSurface(_savedBlock, _savedBounds.left, _savedBounds.top,
|
||||||
|
Common::Rect(0, 0, _savedBlock.w, _savedBlock.h));
|
||||||
|
|
||||||
|
_savedBlock.free();
|
||||||
|
_savedBounds = Common::Rect(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::drawRect() {
|
||||||
|
Graphics::ManagedSurface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::drawLine(int x1, int y1, int x2, int y2, int col) {
|
||||||
|
Graphics::ManagedSurface::drawLine(x1, y1, x2, y2, col);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::drawLine() {
|
||||||
|
Graphics::ManagedSurface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::drawBox() {
|
||||||
|
Graphics::ManagedSurface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
|
||||||
|
Graphics::ManagedSurface::drawLine(_orgX1, _orgY2, _orgX2, _orgY2, _lColor);
|
||||||
|
Graphics::ManagedSurface::drawLine(_orgX2, _orgY1, _orgX2, _orgY1, _lColor);
|
||||||
|
Graphics::ManagedSurface::drawLine(_orgX2, _orgY2, _orgX2, _orgY2, _lColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::flipHorizontal(ASurface &dest) {
|
||||||
|
dest.create(this->w, this->h);
|
||||||
|
for (int y = 0; y < h; ++y) {
|
||||||
|
const byte *pSrc = (const byte *)getBasePtr(this->w - 1, y);
|
||||||
|
byte *pDest = (byte *)dest.getBasePtr(0, y);
|
||||||
|
|
||||||
|
for (int x = 0; x < w; ++x, --pSrc, ++pDest)
|
||||||
|
*pDest = *pSrc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::moveBufferLeft() {
|
||||||
|
byte *p = (byte *)getPixels();
|
||||||
|
Common::copy(p + TILE_WIDTH, p + (w * h), p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::moveBufferRight() {
|
||||||
|
byte *p = (byte *)getPixels();
|
||||||
|
Common::copy_backward(p, p + (pitch * h) - TILE_WIDTH, p + (pitch * h));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::moveBufferUp() {
|
||||||
|
byte *p = (byte *)getPixels();
|
||||||
|
Common::copy(p + (pitch * TILE_HEIGHT), p + (pitch * h), p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASurface::moveBufferDown() {
|
||||||
|
byte *p = (byte *)getPixels();
|
||||||
|
Common::copy_backward(p, p + (pitch * (h - TILE_HEIGHT)), p + (pitch * h));
|
||||||
|
}
|
||||||
|
|
||||||
bool ASurface::clip(Common::Rect &r) {
|
bool ASurface::clip(Common::Rect &r) {
|
||||||
int skip;
|
int skip;
|
||||||
_leftSkip = _rightSkip = 0;
|
_leftSkip = _rightSkip = 0;
|
||||||
@ -181,196 +291,4 @@ bool ASurface::clip(Common::Rect &r) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASurface::plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt) {
|
|
||||||
SpriteFrame *frame = sprite->getFrame(frameNum);
|
|
||||||
Common::Rect r(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h);
|
|
||||||
|
|
||||||
if (!clip(r)) {
|
|
||||||
_lastBoundsX = r.left;
|
|
||||||
_lastBoundsY = r.top;
|
|
||||||
_lastBoundsW = r.width();
|
|
||||||
_lastBoundsH = r.height();
|
|
||||||
|
|
||||||
plotF(frame, pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::transBlitFrom(ASurface *src, const Common::Point &destPos) {
|
|
||||||
if (getPixels() == nullptr)
|
|
||||||
create(w, h);
|
|
||||||
|
|
||||||
for (int yp = 0; yp < src->h; ++yp) {
|
|
||||||
const byte *srcP = (const byte *)src->getBasePtr(0, yp);
|
|
||||||
byte *destP = (byte *)getBasePtr(destPos.x, destPos.y + yp);
|
|
||||||
|
|
||||||
for (int xp = 0; xp < this->w; ++xp, ++srcP, ++destP) {
|
|
||||||
if (*srcP != TRANSPARENCY)
|
|
||||||
*destP = *srcP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::transBlitFrom(ASurface *src, const Common::Rect &bounds) {
|
|
||||||
const int SCALE_LIMIT = 0x100;
|
|
||||||
int scaleX = SCALE_LIMIT * bounds.width() / src->w;
|
|
||||||
int scaleY = SCALE_LIMIT * bounds.height() / src->h;
|
|
||||||
int scaleXCtr = 0, scaleYCtr = 0;
|
|
||||||
|
|
||||||
for (int yCtr = 0, destY = bounds.top; yCtr < src->h; ++yCtr) {
|
|
||||||
// Handle skipping lines if Y scaling
|
|
||||||
scaleYCtr += scaleY;
|
|
||||||
if (scaleYCtr < SCALE_LIMIT)
|
|
||||||
continue;
|
|
||||||
scaleYCtr -= SCALE_LIMIT;
|
|
||||||
|
|
||||||
// Handle off-screen lines
|
|
||||||
if (destY >= this->h)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (destY >= 0) {
|
|
||||||
// Handle drawing the line
|
|
||||||
const byte *pSrc = (const byte *)src->getBasePtr(0, yCtr);
|
|
||||||
byte *pDest = (byte *)getBasePtr(bounds.left, destY);
|
|
||||||
scaleXCtr = 0;
|
|
||||||
int x = bounds.left;
|
|
||||||
|
|
||||||
for (int xCtr = 0; xCtr < src->w; ++xCtr, ++pSrc) {
|
|
||||||
// Handle horizontal scaling
|
|
||||||
scaleXCtr += scaleX;
|
|
||||||
if (scaleXCtr < SCALE_LIMIT)
|
|
||||||
continue;
|
|
||||||
scaleXCtr -= SCALE_LIMIT;
|
|
||||||
|
|
||||||
// Only handle on-screen pixels
|
|
||||||
if (x >= this->w)
|
|
||||||
break;
|
|
||||||
if (x >= 0 && *pSrc != 0)
|
|
||||||
*pDest = *pSrc;
|
|
||||||
|
|
||||||
++pDest;
|
|
||||||
++x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
++destY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::transBlitFrom(ASurface &src) {
|
|
||||||
blitFrom(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::blitFrom(const Graphics::Surface &src) {
|
|
||||||
assert(w >= src.w && h >= src.h);
|
|
||||||
for (int y = 0; y < src.h; ++y) {
|
|
||||||
const byte *srcP = (const byte *)src.getBasePtr(0, y);
|
|
||||||
byte *destP = (byte *)getBasePtr(0, y);
|
|
||||||
Common::copy(srcP, srcP + src.w, destP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::copyBuffer(Graphics::Surface *src) {
|
|
||||||
blitFrom(*src);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
|
|
||||||
sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::plotB(SpriteFrame *frame, const Common::Point &pt) {
|
|
||||||
sPlotB(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
|
|
||||||
transBlitFrom(frame, bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
|
|
||||||
ASurface flippedFrame;
|
|
||||||
frame->flipHorizontal(flippedFrame);
|
|
||||||
|
|
||||||
transBlitFrom(&flippedFrame, bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::copyBlock(ASurface *src, const Common::Rect &bounds) {
|
|
||||||
copyRectToSurface(*src, bounds.left, bounds.top, bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::copyTo(ASurface *dest) {
|
|
||||||
if (dest->empty())
|
|
||||||
dest->create(this->w, this->h);
|
|
||||||
|
|
||||||
dest->blitFrom(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::saveBlock(const Common::Rect &bounds) {
|
|
||||||
_savedBounds = bounds;
|
|
||||||
_savedBounds.clip(Common::Rect(0, 0, this->w, this->h));
|
|
||||||
|
|
||||||
_savedBlock.free();
|
|
||||||
_savedBlock.create(bounds.width(), bounds.height(),
|
|
||||||
Graphics::PixelFormat::createFormatCLUT8());
|
|
||||||
_savedBlock.copyRectToSurface(*this, 0, 0, _savedBounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::restoreBlock() {
|
|
||||||
if (!_savedBounds.isEmpty()) {
|
|
||||||
copyRectToSurface(_savedBlock, _savedBounds.left, _savedBounds.top,
|
|
||||||
Common::Rect(0, 0, _savedBlock.w, _savedBlock.h));
|
|
||||||
|
|
||||||
_savedBlock.free();
|
|
||||||
_savedBounds = Common::Rect(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::drawRect() {
|
|
||||||
Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _orgX2, _orgY2), _lColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::drawLine(int x1, int y1, int x2, int y2, int col) {
|
|
||||||
Graphics::Surface::drawLine(x1, y1, x2, y2, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::drawLine() {
|
|
||||||
Graphics::Surface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::drawBox() {
|
|
||||||
Graphics::Surface::drawLine(_orgX1, _orgY1, _orgX2, _orgY1, _lColor);
|
|
||||||
Graphics::Surface::drawLine(_orgX1, _orgY2, _orgX2, _orgY2, _lColor);
|
|
||||||
Graphics::Surface::drawLine(_orgX2, _orgY1, _orgX2, _orgY1, _lColor);
|
|
||||||
Graphics::Surface::drawLine(_orgX2, _orgY2, _orgX2, _orgY2, _lColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::flipHorizontal(ASurface &dest) {
|
|
||||||
dest.create(this->w, this->h);
|
|
||||||
for (int y = 0; y < h; ++y) {
|
|
||||||
const byte *pSrc = (const byte *)getBasePtr(this->w - 1, y);
|
|
||||||
byte *pDest = (byte *)dest.getBasePtr(0, y);
|
|
||||||
|
|
||||||
for (int x = 0; x < w; ++x, --pSrc, ++pDest)
|
|
||||||
*pDest = *pSrc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::moveBufferLeft() {
|
|
||||||
byte *p = (byte *)getPixels();
|
|
||||||
Common::copy(p + TILE_WIDTH, p + (w * h), p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::moveBufferRight() {
|
|
||||||
byte *p = (byte *)getPixels();
|
|
||||||
Common::copy_backward(p, p + (pitch * h) - TILE_WIDTH, p + (pitch * h));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::moveBufferUp() {
|
|
||||||
byte *p = (byte *)getPixels();
|
|
||||||
Common::copy(p + (pitch * TILE_HEIGHT), p + (pitch * h), p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ASurface::moveBufferDown() {
|
|
||||||
byte *p = (byte *)getPixels();
|
|
||||||
Common::copy_backward(p, p + (pitch * (h - TILE_HEIGHT)), p + (pitch * h));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End of namespace Access
|
} // End of namespace Access
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/memstream.h"
|
#include "common/memstream.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/managed_surface.h"
|
||||||
#include "access/data.h"
|
#include "access/data.h"
|
||||||
|
|
||||||
namespace Access {
|
namespace Access {
|
||||||
@ -35,7 +35,7 @@ namespace Access {
|
|||||||
class SpriteResource;
|
class SpriteResource;
|
||||||
class SpriteFrame;
|
class SpriteFrame;
|
||||||
|
|
||||||
class ASurface : public Graphics::Surface {
|
class ASurface : virtual public Graphics::ManagedSurface {
|
||||||
private:
|
private:
|
||||||
Graphics::Surface _savedBlock;
|
Graphics::Surface _savedBlock;
|
||||||
|
|
||||||
@ -61,14 +61,8 @@ public:
|
|||||||
|
|
||||||
virtual ~ASurface();
|
virtual ~ASurface();
|
||||||
|
|
||||||
void create(uint16 width, uint16 height);
|
|
||||||
|
|
||||||
bool empty() const { return w == 0 || h == 0 || pixels == nullptr; }
|
|
||||||
|
|
||||||
void clearBuffer();
|
void clearBuffer();
|
||||||
|
|
||||||
bool clip(Common::Rect &r);
|
|
||||||
|
|
||||||
void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
|
void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,18 +96,8 @@ public:
|
|||||||
virtual void drawLine();
|
virtual void drawLine();
|
||||||
|
|
||||||
virtual void drawBox();
|
virtual void drawBox();
|
||||||
|
|
||||||
virtual void transBlitFrom(ASurface *src, const Common::Point &destPos);
|
|
||||||
|
|
||||||
virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds);
|
virtual void copyBuffer(Graphics::ManagedSurface *src);
|
||||||
|
|
||||||
virtual void transBlitFrom(ASurface &src);
|
|
||||||
|
|
||||||
virtual void blitFrom(const Graphics::Surface &src);
|
|
||||||
|
|
||||||
virtual void copyBuffer(Graphics::Surface *src);
|
|
||||||
|
|
||||||
virtual void addDirtyRect(const Common::Rect &r) {}
|
|
||||||
|
|
||||||
void copyTo(ASurface *dest);
|
void copyTo(ASurface *dest);
|
||||||
|
|
||||||
@ -126,6 +110,8 @@ public:
|
|||||||
void moveBufferUp();
|
void moveBufferUp();
|
||||||
|
|
||||||
void moveBufferDown();
|
void moveBufferDown();
|
||||||
|
|
||||||
|
bool clip(Common::Rect &r);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SpriteFrame : public ASurface {
|
class SpriteFrame : public ASurface {
|
||||||
|
@ -115,7 +115,7 @@ void EventsManager::setCursor(CursorType cursorId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventsManager::setCursorData(Graphics::Surface *src, const Common::Rect &r) {
|
void EventsManager::setCursorData(Graphics::ManagedSurface *src, const Common::Rect &r) {
|
||||||
_invCursor.create(r.width(), r.height(), Graphics::PixelFormat::createFormatCLUT8());
|
_invCursor.create(r.width(), r.height(), Graphics::PixelFormat::createFormatCLUT8());
|
||||||
_invCursor.copyRectToSurface(*src, 0, 0, r);
|
_invCursor.copyRectToSurface(*src, 0, 0, r);
|
||||||
}
|
}
|
||||||
@ -281,8 +281,7 @@ void EventsManager::nextFrame() {
|
|||||||
// Give time to the debugger
|
// Give time to the debugger
|
||||||
_vm->_debugger->onFrame();
|
_vm->_debugger->onFrame();
|
||||||
|
|
||||||
// TODO: Refactor for dirty rects
|
_vm->_screen->update();
|
||||||
_vm->_screen->updateScreen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventsManager::nextTimer() {
|
void EventsManager::nextTimer() {
|
||||||
|
@ -100,7 +100,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Set the image for the inventory cursor
|
* Set the image for the inventory cursor
|
||||||
*/
|
*/
|
||||||
void setCursorData(Graphics::Surface *src, const Common::Rect &r);
|
void setCursorData(Graphics::ManagedSurface *src, const Common::Rect &r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the current cursor Id
|
* Return the current cursor Id
|
||||||
|
@ -130,13 +130,13 @@ void FileManager::openFile(Resource *res, const Common::String &filename) {
|
|||||||
error("Could not open file - %s", filename.c_str());
|
error("Could not open file - %s", filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::loadScreen(Graphics::Surface *dest, int fileNum, int subfile) {
|
void FileManager::loadScreen(Graphics::ManagedSurface *dest, int fileNum, int subfile) {
|
||||||
Resource *res = loadFile(fileNum, subfile);
|
Resource *res = loadFile(fileNum, subfile);
|
||||||
handleScreen(dest, res);
|
handleScreen(dest, res);
|
||||||
delete res;
|
delete res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
|
void FileManager::handleScreen(Graphics::ManagedSurface *dest, Resource *res) {
|
||||||
_vm->_screen->loadRawPalette(res->_stream);
|
_vm->_screen->loadRawPalette(res->_stream);
|
||||||
if (_setPaletteFlag)
|
if (_setPaletteFlag)
|
||||||
_vm->_screen->setPalette();
|
_vm->_screen->setPalette();
|
||||||
@ -147,20 +147,17 @@ void FileManager::handleScreen(Graphics::Surface *dest, Resource *res) {
|
|||||||
res->_size -= res->_stream->pos();
|
res->_size -= res->_stream->pos();
|
||||||
handleFile(res);
|
handleFile(res);
|
||||||
|
|
||||||
if (dest != _vm->_screen)
|
Graphics::Surface destSurface = dest->getSubArea(Common::Rect(0, 0,
|
||||||
dest->w = _vm->_screen->w;
|
_vm->_screen->w, _vm->_screen->h));
|
||||||
|
|
||||||
if (dest->w == dest->pitch) {
|
if (destSurface.w == destSurface.pitch) {
|
||||||
res->_stream->read((byte *)dest->getPixels(), dest->w * dest->h);
|
res->_stream->read((byte *)destSurface.getPixels(), destSurface.w * destSurface.h);
|
||||||
} else {
|
} else {
|
||||||
for (int y = 0; y < dest->h; ++y) {
|
for (int y = 0; y < destSurface.h; ++y) {
|
||||||
byte *pDest = (byte *)dest->getBasePtr(0, y);
|
byte *pDest = (byte *)destSurface.getBasePtr(0, y);
|
||||||
res->_stream->read(pDest, dest->w);
|
res->_stream->read(pDest, destSurface.w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dest == _vm->_screen)
|
|
||||||
_vm->_screen->addDirtyRect(Common::Rect(0, 0, dest->w, dest->h));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::loadScreen(int fileNum, int subfile) {
|
void FileManager::loadScreen(int fileNum, int subfile) {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/managed_surface.h"
|
||||||
#include "access/decompress.h"
|
#include "access/decompress.h"
|
||||||
|
|
||||||
namespace Access {
|
namespace Access {
|
||||||
@ -81,7 +81,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Handles loading a screen surface and palette with decoded resource
|
* Handles loading a screen surface and palette with decoded resource
|
||||||
*/
|
*/
|
||||||
void handleScreen(Graphics::Surface *dest, Resource *res);
|
void handleScreen(Graphics::ManagedSurface *dest, Resource *res);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open up a sub-file container file
|
* Open up a sub-file container file
|
||||||
@ -133,7 +133,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Load a screen resource onto a designated surface
|
* Load a screen resource onto a designated surface
|
||||||
*/
|
*/
|
||||||
void loadScreen(Graphics::Surface *dest, int fileNum, int subfile);
|
void loadScreen(Graphics::ManagedSurface *dest, int fileNum, int subfile);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End of namespace Access
|
} // End of namespace Access
|
||||||
|
@ -151,13 +151,12 @@ void Font::drawString(ASurface *s, const Common::String &msg, const Common::Poin
|
|||||||
|
|
||||||
int Font::drawChar(ASurface *s, char c, Common::Point &pt) {
|
int Font::drawChar(ASurface *s, char c, Common::Point &pt) {
|
||||||
Graphics::Surface &ch = _chars[c - ' '];
|
Graphics::Surface &ch = _chars[c - ' '];
|
||||||
|
Graphics::Surface dest = s->getSubArea(Common::Rect(pt.x, pt.y, pt.x + ch.w, pt.y + ch.h));
|
||||||
s->addDirtyRect(Common::Rect(pt.x, pt.y, pt.x + ch.w, pt.y + ch.h));
|
|
||||||
|
|
||||||
// Loop through the lines of the character
|
// Loop through the lines of the character
|
||||||
for (int y = 0; y < ch.h; ++y) {
|
for (int y = 0; y < ch.h; ++y) {
|
||||||
byte *pSrc = (byte *)ch.getBasePtr(0, y);
|
byte *pSrc = (byte *)ch.getBasePtr(0, y);
|
||||||
byte *pDest = (byte *)s->getBasePtr(pt.x, pt.y + y);
|
byte *pDest = (byte *)dest.getBasePtr(0, y);
|
||||||
|
|
||||||
// Loop through the horizontal pixels of the line
|
// Loop through the horizontal pixels of the line
|
||||||
for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) {
|
for (int x = 0; x < ch.w; ++x, ++pSrc, ++pDest) {
|
||||||
|
@ -69,8 +69,6 @@ void Screen::clearScreen() {
|
|||||||
clearBuffer();
|
clearBuffer();
|
||||||
if (_vesaMode)
|
if (_vesaMode)
|
||||||
_vm->_clearSummaryFlag = true;
|
_vm->_clearSummaryFlag = true;
|
||||||
|
|
||||||
addDirtyRect(Common::Rect(0, 0, this->w, this->h));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::setDisplayScan() {
|
void Screen::setDisplayScan() {
|
||||||
@ -89,28 +87,14 @@ void Screen::setPanel(int num) {
|
|||||||
_msVirtualOffset = _virtualOffsetsTable[num];
|
_msVirtualOffset = _virtualOffsetsTable[num];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::updateScreen() {
|
void Screen::update() {
|
||||||
if (_vm->_startup >= 0) {
|
if (_vm->_startup >= 0) {
|
||||||
if (--_vm->_startup == -1)
|
if (--_vm->_startup == -1)
|
||||||
_fadeIn = true;
|
_fadeIn = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
markAllDirty();//****DEBUG****
|
||||||
// Merge the dirty rects
|
Graphics::Screen::update();
|
||||||
mergeDirtyRects();
|
|
||||||
|
|
||||||
// Loop through copying dirty areas to the physical screen
|
|
||||||
Common::List<Common::Rect>::iterator i;
|
|
||||||
for (i = _dirtyRects.begin(); i != _dirtyRects.end(); ++i) {
|
|
||||||
const Common::Rect &r = *i;
|
|
||||||
const byte *srcP = (const byte *)getBasePtr(r.left, r.top);
|
|
||||||
g_system->copyRectToScreen(srcP, this->pitch, r.left, r.top,
|
|
||||||
r.width(), r.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Signal the physical screen to update
|
|
||||||
g_system->updateScreen();
|
|
||||||
_dirtyRects.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::setInitialPalettte() {
|
void Screen::setInitialPalettte() {
|
||||||
@ -153,7 +137,7 @@ void Screen::loadRawPalette(Common::SeekableReadStream *stream) {
|
|||||||
|
|
||||||
void Screen::updatePalette() {
|
void Screen::updatePalette() {
|
||||||
g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
|
g_system->getPaletteManager()->setPalette(&_tempPalette[0], 0, PALETTE_COUNT);
|
||||||
updateScreen();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::savePalette() {
|
void Screen::savePalette() {
|
||||||
@ -293,22 +277,7 @@ void Screen::drawBox() {
|
|||||||
ASurface::drawBox();
|
ASurface::drawBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::transBlitFrom(ASurface *src, const Common::Point &destPos) {
|
void Screen::copyBuffer(Graphics::ManagedSurface *src) {
|
||||||
addDirtyRect(Common::Rect(destPos.x, destPos.y, destPos.x + src->w, destPos.y + src->h));
|
|
||||||
ASurface::transBlitFrom(src, destPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Screen::transBlitFrom(ASurface *src, const Common::Rect &bounds) {
|
|
||||||
addDirtyRect(bounds);
|
|
||||||
ASurface::transBlitFrom(src, bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Screen::blitFrom(const Graphics::Surface &src) {
|
|
||||||
addDirtyRect(Common::Rect(0, 0, src.w, src.h));
|
|
||||||
ASurface::blitFrom(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Screen::copyBuffer(Graphics::Surface *src) {
|
|
||||||
addDirtyRect(Common::Rect(0, 0, src->w, src->h));
|
addDirtyRect(Common::Rect(0, 0, src->w, src->h));
|
||||||
ASurface::copyBuffer(src);
|
ASurface::copyBuffer(src);
|
||||||
}
|
}
|
||||||
@ -349,51 +318,7 @@ void Screen::cyclePaletteBackwards() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Screen::flashPalette(int count) {
|
void Screen::flashPalette(int count) {
|
||||||
warning("TODO: Implement flashPalette");
|
// No implementation needed in ScummVM
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::addDirtyRect(const Common::Rect &r) {
|
|
||||||
_dirtyRects.push_back(r);
|
|
||||||
assert(r.isValidRect() && r.width() > 0 && r.height() > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Screen::mergeDirtyRects() {
|
|
||||||
Common::List<Common::Rect>::iterator rOuter, rInner;
|
|
||||||
|
|
||||||
// Ensure dirty rect list has at least two entries
|
|
||||||
rOuter = _dirtyRects.begin();
|
|
||||||
for (int i = 0; i < 2; ++i, ++rOuter) {
|
|
||||||
if (rOuter == _dirtyRects.end())
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process the dirty rect list to find any rects to merge
|
|
||||||
for (rOuter = _dirtyRects.begin(); rOuter != _dirtyRects.end(); ++rOuter) {
|
|
||||||
rInner = rOuter;
|
|
||||||
while (++rInner != _dirtyRects.end()) {
|
|
||||||
|
|
||||||
if ((*rOuter).intersects(*rInner)) {
|
|
||||||
// these two rectangles overlap or
|
|
||||||
// are next to each other - merge them
|
|
||||||
|
|
||||||
unionRectangle(*rOuter, *rOuter, *rInner);
|
|
||||||
|
|
||||||
// remove the inner rect from the list
|
|
||||||
_dirtyRects.erase(rInner);
|
|
||||||
|
|
||||||
// move back to beginning of list
|
|
||||||
rInner = rOuter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Screen::unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2) {
|
|
||||||
destRect = src1;
|
|
||||||
destRect.extend(src2);
|
|
||||||
|
|
||||||
return !destRect.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // End of namespace Access
|
} // End of namespace Access
|
||||||
|
@ -26,15 +26,13 @@
|
|||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/rect.h"
|
#include "common/rect.h"
|
||||||
#include "common/stream.h"
|
#include "common/stream.h"
|
||||||
|
#include "graphics/screen.h"
|
||||||
#include "access/asurface.h"
|
#include "access/asurface.h"
|
||||||
|
|
||||||
namespace Access {
|
namespace Access {
|
||||||
|
|
||||||
class AccessEngine;
|
class AccessEngine;
|
||||||
|
|
||||||
#define PALETTE_COUNT 256
|
|
||||||
#define PALETTE_SIZE (256 * 3)
|
|
||||||
|
|
||||||
struct ScreenSave {
|
struct ScreenSave {
|
||||||
int _clipWidth;
|
int _clipWidth;
|
||||||
int _clipHeight;
|
int _clipHeight;
|
||||||
@ -47,7 +45,7 @@ struct ScreenSave {
|
|||||||
int _screenYOff;
|
int _screenYOff;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Screen : public ASurface {
|
class Screen : public virtual ASurface, public virtual Graphics::Screen {
|
||||||
private:
|
private:
|
||||||
AccessEngine *_vm;
|
AccessEngine *_vm;
|
||||||
byte _tempPalette[PALETTE_SIZE];
|
byte _tempPalette[PALETTE_SIZE];
|
||||||
@ -66,10 +64,6 @@ private:
|
|||||||
Common::List<Common::Rect> _dirtyRects;
|
Common::List<Common::Rect> _dirtyRects;
|
||||||
|
|
||||||
void updatePalette();
|
void updatePalette();
|
||||||
|
|
||||||
void mergeDirtyRects();
|
|
||||||
|
|
||||||
bool unionRectangle(Common::Rect &destRect, const Common::Rect &src1, const Common::Rect &src2);
|
|
||||||
public:
|
public:
|
||||||
int _vesaMode;
|
int _vesaMode;
|
||||||
int _startColor, _numColors;
|
int _startColor, _numColors;
|
||||||
@ -87,6 +81,11 @@ public:
|
|||||||
bool _screenChangeFlag;
|
bool _screenChangeFlag;
|
||||||
bool _fadeIn;
|
bool _fadeIn;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Updates the screen
|
||||||
|
*/
|
||||||
|
virtual void update();
|
||||||
|
|
||||||
virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
|
virtual void copyBlock(ASurface *src, const Common::Rect &bounds);
|
||||||
|
|
||||||
virtual void restoreBlock();
|
virtual void restoreBlock();
|
||||||
@ -95,15 +94,7 @@ public:
|
|||||||
|
|
||||||
virtual void drawBox();
|
virtual void drawBox();
|
||||||
|
|
||||||
virtual void transBlitFrom(ASurface *src, const Common::Point &destPos);
|
virtual void copyBuffer(Graphics::ManagedSurface *src);
|
||||||
|
|
||||||
virtual void transBlitFrom(ASurface *src, const Common::Rect &bounds);
|
|
||||||
|
|
||||||
virtual void blitFrom(const Graphics::Surface &src);
|
|
||||||
|
|
||||||
virtual void copyBuffer(Graphics::Surface *src);
|
|
||||||
|
|
||||||
virtual void addDirtyRect(const Common::Rect &r);
|
|
||||||
public:
|
public:
|
||||||
Screen(AccessEngine *vm);
|
Screen(AccessEngine *vm);
|
||||||
|
|
||||||
@ -113,11 +104,6 @@ public:
|
|||||||
|
|
||||||
void setPanel(int num);
|
void setPanel(int num);
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the underlying screen
|
|
||||||
*/
|
|
||||||
void updateScreen();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fade out screen
|
* Fade out screen
|
||||||
*/
|
*/
|
||||||
|
@ -157,7 +157,7 @@ void VideoPlayer::playVideo() {
|
|||||||
|
|
||||||
// If the video is playing on the screen surface, add a dirty rect
|
// If the video is playing on the screen surface, add a dirty rect
|
||||||
if (_vidSurface == _vm->_screen)
|
if (_vidSurface == _vm->_screen)
|
||||||
_vm->_screen->addDirtyRect(_videoBounds);
|
_vm->_screen->markAllDirty();
|
||||||
|
|
||||||
getFrame();
|
getFrame();
|
||||||
if (++_videoFrame == _frameCount) {
|
if (++_videoFrame == _frameCount) {
|
||||||
|
@ -719,7 +719,7 @@ bool AccessEngine::playMovie(const Common::String &filename, const Common::Point
|
|||||||
g_system->getPaletteManager()->setPalette(palette, 0, 256);
|
g_system->getPaletteManager()->setPalette(palette, 0, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
_screen->updateScreen();
|
_screen->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user