ACCESS: Simplified surface creation, added drawing for scaled flipped images

This commit is contained in:
Paul Gilbert 2014-08-18 20:15:43 -04:00
parent b6dc7a1dd4
commit ad0be89459
4 changed files with 37 additions and 9 deletions

View file

@ -153,8 +153,8 @@ void AccessEngine::initialize() {
_screen = new Screen(this);
_sound = new SoundManager(this, _mixer);
_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
_buffer2.create(g_system->getWidth(), g_system->getHeight(), Graphics::PixelFormat::createFormatCLUT8());
_buffer1.create(g_system->getWidth() + TILE_WIDTH, g_system->getHeight());
_buffer2.create(g_system->getWidth(), g_system->getHeight());
}
Common::Error AccessEngine::run() {
@ -272,7 +272,7 @@ void AccessEngine::plotList1() {
bounds.setWidth(bounds.width() / _scale);
if (ie._flags & 2) {
_buffer2.sPlotB(frame, Common::Point(bounds.left, bounds.top));
_buffer2.sPlotB(frame, destBounds);
} else {
_buffer2.sPlotF(frame, destBounds);
}

View file

@ -59,7 +59,7 @@ SpriteResource::~SpriteResource() {
SpriteFrame::SpriteFrame(AccessEngine *vm, Common::MemoryReadStream &stream, int frameSize) {
int xSize = stream.readUint16LE();
int ySize = stream.readUint16LE();
create(xSize, ySize, Graphics::PixelFormat::createFormatCLUT8());
create(xSize, ySize);
// Empty surface
byte *data = (byte *)getPixels();
@ -138,6 +138,10 @@ ASurface::~ASurface() {
_savedBlock.free();
}
void ASurface::create(uint16 width, uint16 height) {
Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
}
void ASurface::clearBuffer() {
byte *pSrc = (byte *)getPixels();
Common::fill(pSrc, pSrc + w * h, 0);
@ -301,8 +305,10 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
}
}
void ASurface::sPlotB(SpriteFrame *frame, const Common::Point &pt) {
frame->copyTo(this, pt);
void ASurface::sPlotB(SpriteFrame *frame, const Common::Rect &bounds) {
ASurface flippedFrame;
frame->flipHorizontal(flippedFrame);
flippedFrame.copyTo(this, bounds);
}
void ASurface::sPlotF(SpriteFrame *frame, const Common::Rect &bounds) {
@ -341,4 +347,16 @@ void ASurface::drawRect() {
Graphics::Surface::fillRect(Common::Rect(_orgX1, _orgY1, _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;
}
}
} // End of namespace Access

View file

@ -39,6 +39,8 @@ class ASurface : public Graphics::Surface {
private:
Graphics::Surface _savedBlock;
Common::Rect _savedBounds;
void flipHorizontal(ASurface &dest);
public:
static int _leftSkip, _rightSkip;
static int _topSkip, _bottomSkip;
@ -56,6 +58,8 @@ public:
public:
virtual ~ASurface();
void create(uint16 width, uint16 height);
void clearBuffer();
void copyBuffer(Graphics::Surface *src) { copyFrom(*src); }
@ -64,10 +68,16 @@ public:
void plotImage(SpriteResource *sprite, int frameNum, const Common::Point &pt);
void sPlotB(SpriteFrame *frame, const Common::Point &pt);
/**
* Scaled draw frame
*/
void sPlotF(SpriteFrame *frame, const Common::Rect &bounds);
/**
* Scaled flipped horizontal draw frame
*/
void sPlotB(SpriteFrame *frame, const Common::Rect &bounds);
void plotB(SpriteFrame *frame, const Common::Point &pt);
void copyBlock(ASurface *src, const Common::Rect &bounds);

View file

@ -35,7 +35,7 @@ namespace Access {
#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
Screen::Screen(AccessEngine *vm) : _vm(vm) {
create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
create(320, 200);
Common::fill(&_tempPalette[0], &_tempPalette[PALETTE_SIZE], 0);
Common::fill(&_manPal[0], &_manPal[0x60], 0);
Common::fill(&_scaleTable1[0], &_scaleTable1[256], 0);