diff options
Diffstat (limited to 'engines/gob')
34 files changed, 460 insertions, 729 deletions
diff --git a/engines/gob/demos/demoplayer.cpp b/engines/gob/demos/demoplayer.cpp index ea72a80396..4ceca3ce24 100644 --- a/engines/gob/demos/demoplayer.cpp +++ b/engines/gob/demos/demoplayer.cpp @@ -123,7 +123,7 @@ void DemoPlayer::init() { void DemoPlayer::clearScreen() { debugC(1, kDebugDemo, "Clearing the screen"); - _vm->_video->clearSurf(*_vm->_draw->_backSurface); + _vm->_draw->_backSurface->clear(); _vm->_draw->forceBlit(); _vm->_video->retrace(); } @@ -244,10 +244,11 @@ void DemoPlayer::playVideoDoubled(int slot) { int16 wD = (rect->left * 2) + (w * 2); int16 hD = (rect->top * 2) + (h * 2); - _vm->_video->drawSpriteDouble(*_vm->_draw->_spritesArray[0], *_vm->_draw->_frontSurface, - rect->left, rect->top, rect->right - 1, rect->bottom - 1, rect->left, rect->top, 0); - _vm->_draw->dirtiedRect(_vm->_draw->_frontSurface, - rect->left * 2, rect->top * 2, wD, hD); + _vm->_draw->_frontSurface->blitScaled(*_vm->_draw->_spritesArray[0], + rect->left, rect->top, rect->right - 1, rect->bottom - 1, rect->left * 2, rect->top * 2, 2); + + _vm->_draw->dirtiedRect(_vm->_draw->_frontSurface, + rect->left * 2, rect->top * 2, wD, hD); } } diff --git a/engines/gob/draw.cpp b/engines/gob/draw.cpp index 62b9a5e630..960f4e9e34 100644 --- a/engines/gob/draw.cpp +++ b/engines/gob/draw.cpp @@ -263,10 +263,10 @@ void Draw::blitInvalidated() { _vm->_video->_doRangeClamp = false; for (int i = 0; i < _invalidatedCount; i++) { - _vm->_video->drawSprite(*_backSurface, *_frontSurface, + _frontSurface->blit(*_backSurface, _invalidatedLefts[i], _invalidatedTops[i], _invalidatedRights[i], _invalidatedBottoms[i], - _invalidatedLefts[i], _invalidatedTops[i], 0); + _invalidatedLefts[i], _invalidatedTops[i]); _vm->_video->dirtyRectsAdd(_invalidatedLefts[i], _invalidatedTops[i], _invalidatedRights[i], _invalidatedBottoms[i]); } @@ -300,7 +300,7 @@ void Draw::dirtiedRect(int16 surface, dirtiedRect(_spritesArray[surface], left, top, right, bottom); } -void Draw::dirtiedRect(SurfaceDescPtr surface, +void Draw::dirtiedRect(SurfacePtr surface, int16 left, int16 top, int16 right, int16 bottom) { if (surface == _backSurface) @@ -316,7 +316,7 @@ void Draw::initSpriteSurf(int16 index, int16 width, int16 height, _spritesArray[index] = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width, height, flags); - _vm->_video->clearSurf(*_spritesArray[index]); + _spritesArray[index]->clear(); } void Draw::adjustCoords(char adjust, int16 *coord1, int16 *coord2) { @@ -381,14 +381,14 @@ int Draw::stringLength(const char *str, int16 fontIndex) { } void Draw::drawString(const char *str, int16 x, int16 y, int16 color1, int16 color2, - int16 transp, SurfaceDesc &dest, const Font &font) { + int16 transp, Surface &dest, const Font &font) { while (*str != '\0') { const int16 charRight = x + font.getCharWidth(*str); const int16 charBottom = y + font.getCharHeight(); if ((charRight <= dest.getWidth()) && (charBottom <= dest.getHeight())) - _vm->_video->drawLetter(*str, x, y, font, transp, color1, color2, dest); + font.drawLetter(dest, *str, x, y, color1, color2, transp); x += font.getCharWidth(*str); str++; @@ -548,14 +548,10 @@ void Draw::forceBlit(bool backwards) { return; if (!backwards) { - _vm->_video->drawSprite(*_backSurface, *_frontSurface, 0, 0, - _backSurface->getWidth() - 1, _backSurface->getHeight() - 1, - 0, 0, 0); + _frontSurface->blit(*_backSurface); _vm->_video->dirtyRectsAll(); } else - _vm->_video->drawSprite(*_frontSurface, *_backSurface, 0, 0, - _frontSurface->getWidth() - 1, _frontSurface->getHeight() - 1, - 0, 0, 0); + _backSurface->blit(*_frontSurface); } @@ -602,7 +598,7 @@ const int16 Draw::_wobbleTable[360] = { -0x0A03, -0x08E8, -0x07CC, -0x06B0, -0x0593, -0x0476, -0x0359, -0x023B, -0x011D }; -void Draw::wobble(SurfaceDesc &surfDesc) { +void Draw::wobble(Surface &surfDesc) { int16 amplitude = 32; uint16 curFrame = 0; uint16 frameWobble = 0; @@ -626,16 +622,14 @@ void Draw::wobble(SurfaceDesc &surfDesc) { amplitude--; for (uint16 y = 0; y < _vm->_height; y++) - _vm->_video->drawSprite(surfDesc, *_frontSurface, - 0, y, _vm->_width - 1, y, offsets[y], y, 0); + _frontSurface->blit(surfDesc, 0, y, _vm->_width - 1, y, offsets[y], y); _vm->_palAnim->fadeStep(0); _vm->_video->dirtyRectsAll(); _vm->_video->waitRetrace(); } - _vm->_video->drawSprite(surfDesc, *_frontSurface, - 0, 0, _vm->_width - 1, _vm->_height - 1, 0, 0, 0); + _frontSurface->blit(surfDesc); _applyPal = false; _invalidatedCount = 0; diff --git a/engines/gob/draw.h b/engines/gob/draw.h index cbadde8e27..fe37382666 100644 --- a/engines/gob/draw.h +++ b/engines/gob/draw.h @@ -66,7 +66,7 @@ public: int16 top; int16 width; int16 height; - SurfaceDescPtr savedSurface; + SurfacePtr savedSurface; }; int16 _renderFlags; @@ -98,7 +98,7 @@ public: FontToSprite _fontToSprite[4]; Font *_fonts[kFontCount]; - Common::Array<SurfaceDescPtr> _spritesArray; + Common::Array<SurfacePtr> _spritesArray; int16 _invalidatedCount; int16 _invalidatedLefts[30]; @@ -112,8 +112,8 @@ public: bool _paletteCleared; bool _applyPal; - SurfaceDescPtr _backSurface; - SurfaceDescPtr _frontSurface; + SurfacePtr _backSurface; + SurfacePtr _frontSurface; int16 _unusedPalette1[18]; int16 _unusedPalette2[16]; @@ -137,9 +137,9 @@ public: int32 _cursorHotspotXVar; int32 _cursorHotspotYVar; - SurfaceDescPtr _cursorSprites; - SurfaceDescPtr _cursorSpritesBack; - SurfaceDescPtr _scummvmCursor; + SurfacePtr _cursorSprites; + SurfacePtr _cursorSpritesBack; + SurfacePtr _scummvmCursor; int16 _cursorAnim; int8 _cursorAnimLow[40]; @@ -174,7 +174,7 @@ public: void clearPalette(); void dirtiedRect(int16 surface, int16 left, int16 top, int16 right, int16 bottom); - void dirtiedRect(SurfaceDescPtr surface, int16 left, int16 top, int16 right, int16 bottom); + void dirtiedRect(SurfacePtr surface, int16 left, int16 top, int16 right, int16 bottom); void initSpriteSurf(int16 index, int16 width, int16 height, int16 flags); void freeSprite(int16 index) { @@ -187,7 +187,7 @@ public: } int stringLength(const char *str, int16 fontIndex); void drawString(const char *str, int16 x, int16 y, int16 color1, int16 color2, - int16 transp, SurfaceDesc &dest, const Font &font); + int16 transp, Surface &dest, const Font &font); void printTextCentered(int16 id, int16 left, int16 top, int16 right, int16 bottom, const char *str, int16 fontIndex, int16 color); void oPlaytoons_sub_F_1B( uint16 id, int16 left, int16 top, int16 right, int16 bottom, char *paramStr, int16 var3, int16 var4, int16 shortId); @@ -196,7 +196,7 @@ public: void forceBlit(bool backwards = false); static const int16 _wobbleTable[360]; - void wobble(SurfaceDesc &surfDesc); + void wobble(Surface &surfDesc); Font *loadFont(const char *path) const; bool loadFont(int fontIndex, const char *path); @@ -267,7 +267,7 @@ public: virtual ~Draw_Fascination() {} virtual void spriteOperation(int16 operation); - void decompWin(int16 x, int16 y, SurfaceDescPtr destPtr); + void decompWin(int16 x, int16 y, SurfacePtr destPtr); void drawWin(int16 fct); void saveWin(int16 id); void restoreWin(int16 id); diff --git a/engines/gob/draw_fascin.cpp b/engines/gob/draw_fascin.cpp index dcb76d722c..86e5cb8314 100644 --- a/engines/gob/draw_fascin.cpp +++ b/engines/gob/draw_fascin.cpp @@ -40,7 +40,7 @@ Draw_Fascination::Draw_Fascination(GobEngine *vm) : Draw_v2(vm) { void Draw_Fascination::spriteOperation(int16 operation) { int16 len; int16 x, y; - SurfaceDescPtr sourceSurf, destSurf; + SurfacePtr sourceSurf, destSurf; bool deltaVeto; int16 left; int16 ratio; @@ -149,26 +149,24 @@ void Draw_Fascination::spriteOperation(int16 operation) { if (!sourceSurf || !destSurf) break; - _vm->_video->drawSprite(*_spritesArray[_sourceSurface], - *_spritesArray[_destSurface], + _spritesArray[_destSurface]->blit(*_spritesArray[_sourceSurface], _spriteLeft, spriteTop, _spriteLeft + _spriteRight - 1, _spriteTop + _spriteBottom - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1); break; case DRAW_PUTPIXEL: - _vm->_video->putPixel(_destSpriteX, _destSpriteY, _frontColor, - *_spritesArray[_destSurface]); + _spritesArray[_destSurface]->putPixel(_destSpriteX, _destSpriteY, _frontColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX, _destSpriteY); break; case DRAW_FILLRECT: - _vm->_video->fillRect(*_spritesArray[_destSurface], destSpriteX, + _spritesArray[_destSurface]->fillRect(destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1, _backColor); @@ -177,15 +175,14 @@ void Draw_Fascination::spriteOperation(int16 operation) { break; case DRAW_DRAWLINE: - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); break; case DRAW_INVALIDATE: - _vm->_video->drawCircle(*_spritesArray[_destSurface], _destSpriteX, + _spritesArray[_destSurface]->drawCircle(_destSpriteX, _destSpriteY, _spriteRight, _frontColor); dirtiedRect(_destSurface, _destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, @@ -227,9 +224,8 @@ void Draw_Fascination::spriteOperation(int16 operation) { byte *dataBuf = _vm->_game->_resources->getTexts() + _textToPrint[1] + 1; len = *dataBuf++; for (int i = 0; i < len; i++, dataBuf += 2) { - _vm->_video->drawLetter(READ_LE_UINT16(dataBuf), _destSpriteX, - _destSpriteY, *font, _transparency, _frontColor, - _backColor, *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], READ_LE_UINT16(dataBuf), + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); } } else { drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor, @@ -238,9 +234,8 @@ void Draw_Fascination::spriteOperation(int16 operation) { } } else { for (int i = 0; i < len; i++) { - _vm->_video->drawLetter(_textToPrint[i], _destSpriteX, - _destSpriteY, *font, _transparency, - _frontColor, _backColor, *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], _textToPrint[i], + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); _destSpriteX += font->getCharWidth(_textToPrint[i]); } } @@ -255,11 +250,10 @@ void Draw_Fascination::spriteOperation(int16 operation) { * _fontToSprite[_fontIndex].height; x = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) % ratio) * _fontToSprite[_fontIndex].width; - _vm->_video->drawSprite(*_spritesArray[_fontToSprite[_fontIndex].sprite], - *_spritesArray[_destSurface], x, y, + _spritesArray[_destSurface]->blit(*_spritesArray[_fontToSprite[_fontIndex].sprite], x, y, x + _fontToSprite[_fontIndex].width - 1, y + _fontToSprite[_fontIndex].height - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); _destSpriteX += _fontToSprite[_fontIndex].width; } } @@ -270,36 +264,28 @@ void Draw_Fascination::spriteOperation(int16 operation) { case DRAW_DRAWBAR: if (_needAdjust != 2) { - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _spriteBottom - 1, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _spriteBottom - 1, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect( _destSpriteX, _destSpriteY, _destSpriteX + 1, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _spriteRight - 1, _destSpriteY, + _spritesArray[_destSurface]->fillRect( _spriteRight - 1, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect( _destSpriteX, _destSpriteY, _spriteRight, _destSpriteY + 1, _frontColor); } else { - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _spriteBottom, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _spriteBottom, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _destSpriteX, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _spriteRight, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_spriteRight, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _destSpriteY, _frontColor); } @@ -308,19 +294,14 @@ void Draw_Fascination::spriteOperation(int16 operation) { case DRAW_CLEARRECT: if ((_backColor != 16) && (_backColor != 144)) { - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, - _spriteRight, _spriteBottom, - _backColor); + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); } dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); break; case DRAW_FILLRECTABS: - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, - _spriteRight, _spriteBottom, _backColor); + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); break; @@ -364,7 +345,7 @@ void Draw_Fascination::drawWin(int16 fct) { int len; Resource *resource; int table[10]; - SurfaceDescPtr tempSrf; + SurfacePtr tempSrf; if (_destSurface == kBackSurface) { @@ -486,9 +467,9 @@ void Draw_Fascination::drawWin(int16 fct) { } if ((_sourceSurface == kBackSurface) && (fct == 0)) { - _vm->_video->drawSprite(*_spritesArray[_sourceSurface], *_spritesArray[_destSurface], + _spritesArray[_destSurface]->blit(*_spritesArray[_sourceSurface], _spriteLeft, _spriteTop, _spriteLeft + _spriteRight - 1, - _spriteTop + _spriteBottom - 1, _destSpriteX, _destSpriteY, _transparency); + _spriteTop + _spriteBottom - 1, _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); if (!found) return; @@ -498,18 +479,18 @@ void Draw_Fascination::drawWin(int16 fct) { for (int i = 9; i >= j; i--) { if (table[i]) - _vm->_video->drawSprite(*_fascinWin[table[i]].savedSurface, *_spritesArray[_destSurface], + _spritesArray[_destSurface]->blit(*_fascinWin[table[i]].savedSurface, _fascinWin[table[i]].left & 7, 0, (_fascinWin[table[i]].left & 7) + _fascinWin[table[i]].width - 1, _fascinWin[table[i]].height - 1, _fascinWin[table[i]].left - _spriteLeft + _destSpriteX, - _fascinWin[table[i]].top - _spriteTop + _destSpriteY, 0); + _fascinWin[table[i]].top - _spriteTop + _destSpriteY); } return; } if (found) { tempSrf = _vm->_video->initSurfDesc(_vm->_global->_videoMode, width - left + 1, height - top + 1, 0); - _vm->_video->drawSprite(*_backSurface, *tempSrf, left, top, width, height, 0, 0, 0); + tempSrf->blit(*_backSurface, left, top, width, height, 0, 0); int max = 0; if (_vm->_global->_curWinId != 0) @@ -517,37 +498,37 @@ void Draw_Fascination::drawWin(int16 fct) { for (int i = 9; i >= max; i--) { if (table[i]) - _vm->_video->drawSprite(*_fascinWin[table[i]].savedSurface, *tempSrf, + tempSrf->blit(*_fascinWin[table[i]].savedSurface, _fascinWin[table[i]].left & 7, 0, (_fascinWin[table[i]].left & 7) + _fascinWin[table[i]].width - 1, _fascinWin[table[i]].height - 1, _fascinWin[table[i]].left - left, - _fascinWin[table[i]].top - top , 0); + _fascinWin[table[i]].top - top); } invalidateRect(left, top, width, height); switch (fct) { case DRAW_BLITSURF: // 0 - move - _vm->_video->drawSprite(*_spritesArray[_sourceSurface], *tempSrf, + tempSrf->blit(*_spritesArray[_sourceSurface], _spriteLeft, _spriteTop, _spriteLeft + _spriteRight - 1, - _spriteTop + _spriteBottom - 1, 0, 0, _transparency); + _spriteTop + _spriteBottom - 1, 0, 0, (_transparency == 0) ? -1 : 0); break; case DRAW_PUTPIXEL: // 1 - put a pixel - _vm->_video->putPixel(0, 0, _frontColor, *tempSrf); + tempSrf->putPixel(0, 0, _frontColor); break; case DRAW_FILLRECT: // 2 - fill rectangle - _vm->_video->fillRect(*tempSrf, 0, 0, _spriteRight - 1, _spriteBottom - 1, _backColor); + tempSrf->fillRect(0, 0, _spriteRight - 1, _spriteBottom - 1, _backColor); break; case DRAW_DRAWLINE: // 3 - draw line - _vm->_video->drawLine(*tempSrf, 0, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _frontColor); + tempSrf->drawLine(0, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _frontColor); break; case DRAW_INVALIDATE: // 4 - Draw a circle - _vm->_video->drawCircle(*tempSrf, _spriteRight, _spriteRight, _spriteRight, _frontColor); + tempSrf->drawCircle(_spriteRight, _spriteRight, _spriteRight, _frontColor); break; case DRAW_LOADSPRITE: // 5 - Uncompress and load a sprite @@ -557,40 +538,40 @@ void Draw_Fascination::drawWin(int16 fct) { case DRAW_PRINTTEXT: // 6 - Display string len = strlen(_textToPrint); for (int j = 0; j < len; j++) - _vm->_video->drawLetter(_textToPrint[j], j * _fonts[_fontIndex]->getCharWidth(), 0, - *_fonts[_fontIndex], _transparency, _frontColor, _backColor, *tempSrf); + _fonts[_fontIndex]->drawLetter(*tempSrf, _textToPrint[j], + j * _fonts[_fontIndex]->getCharWidth(), 0, _frontColor, _backColor, _transparency); _destSpriteX += len * _fonts[_fontIndex]->getCharWidth(); break; case DRAW_DRAWBAR: // 7 - draw border - _vm->_video->drawLine(*tempSrf, 0, _spriteBottom - _destSpriteY, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _frontColor); - _vm->_video->drawLine(*tempSrf, 0, 0, 0, _spriteBottom - _destSpriteY, _frontColor); - _vm->_video->drawLine(*tempSrf, _spriteRight - _destSpriteX, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _frontColor); - _vm->_video->drawLine(*tempSrf, 0, 0, _spriteRight - _destSpriteX, 0, _frontColor); + tempSrf->drawLine(0, _spriteBottom - _destSpriteY, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _frontColor); + tempSrf->drawLine(0, 0, 0, _spriteBottom - _destSpriteY, _frontColor); + tempSrf->drawLine(_spriteRight - _destSpriteX, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _frontColor); + tempSrf->drawLine(0, 0, _spriteRight - _destSpriteX, 0, _frontColor); break; case DRAW_CLEARRECT: // 8 - clear rectangle if (_backColor < 16) - _vm->_video->fillRect(*tempSrf, 0, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _backColor); + tempSrf->fillRect(0, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _backColor); break; case DRAW_FILLRECTABS: // 9 - fill rectangle, with other coordinates - _vm->_video->fillRect(*tempSrf, 0, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _backColor); + tempSrf->fillRect(0, 0, _spriteRight - _destSpriteX, _spriteBottom - _destSpriteY, _backColor); break; case DRAW_DRAWLETTER: // 10 - Display a character if (_fontToSprite[_fontIndex].sprite == -1) { if (_letterToPrint) - _vm->_video->drawLetter(_letterToPrint, 0, 0, *_fonts[_fontIndex], _transparency, _frontColor, _backColor, *tempSrf); + _fonts[_fontIndex]->drawLetter(*tempSrf, _letterToPrint, 0, 0, _frontColor, _backColor, _transparency); } else { int xx, yy, nn; nn = _spritesArray[_fontToSprite[_fontIndex].sprite]->getWidth() / _fontToSprite[_fontIndex].width; yy = ((_letterToPrint - _fontToSprite[_fontIndex].base) / nn) * _fontToSprite[_fontIndex].height; xx = ((_letterToPrint - _fontToSprite[_fontIndex].base) % nn) * _fontToSprite[_fontIndex].width; - _vm->_video->drawSprite(*_spritesArray[_fontToSprite[_fontIndex].sprite], *tempSrf, + tempSrf->blit(*_spritesArray[_fontToSprite[_fontIndex].sprite], xx, yy, xx + _fontToSprite[_fontIndex].width - 1, - yy + _fontToSprite[_fontIndex].height - 1, 0, 0, _transparency); + yy + _fontToSprite[_fontIndex].height - 1, 0, 0, (_transparency == 0) ? -1 : 0); } break; @@ -606,26 +587,26 @@ void Draw_Fascination::drawWin(int16 fct) { for (; i < 10; i++) { if (table[i]) { int k = table[i]; - _vm->_video->drawSprite(*tempSrf, *_fascinWin[k].savedSurface, + _fascinWin[k].savedSurface->blit(*tempSrf, 0, 0, width - left, height - top, left - _fascinWin[k].left + (_fascinWin[k].left & 7), - top - _fascinWin[k].top, 0); + top - _fascinWin[k].top); // Shift skipped as always set to zero (?) - _vm->_video->drawSprite(*_frontSurface, *tempSrf, + tempSrf->blit(*_frontSurface, MAX(left , _fascinWin[k].left), MAX(top , _fascinWin[k].top), MIN(width , (int16) (_fascinWin[k].left + _fascinWin[k].width - 1)), MIN(height, (int16) (_fascinWin[k].top + _fascinWin[k].height - 1)), MAX(left , _fascinWin[k].left) - left, - MAX(top , _fascinWin[k].top) - top, 0); + MAX(top , _fascinWin[k].top) - top); if (_cursorIndex != -1) - _vm->_video->drawSprite(*_cursorSpritesBack, *tempSrf, + tempSrf->blit(*_cursorSpritesBack, 0, 0, _cursorWidth - 1, _cursorHeight - 1, - _cursorX - left, _cursorY - top, 0); + _cursorX - left, _cursorY - top); for (int j = 9; j > i; j--) { if (table[j] && overlapWin(k, table[j])) { int l = table[j]; - _vm->_video->drawSprite(*_fascinWin[l].savedSurface, *tempSrf, + tempSrf->blit(*_fascinWin[l].savedSurface, MAX(_fascinWin[l].left, _fascinWin[k].left) - _fascinWin[l].left + (_fascinWin[l].left & 7), MAX(_fascinWin[l].top , _fascinWin[k].top ) - _fascinWin[l].top, @@ -634,37 +615,37 @@ void Draw_Fascination::drawWin(int16 fct) { MIN(_fascinWin[l].top + _fascinWin[l].height - 1, _fascinWin[k].top + _fascinWin[k].height - 1) - _fascinWin[l].top, MAX(_fascinWin[l].left, _fascinWin[k].left) - left, - MAX(_fascinWin[l].top , _fascinWin[k].top ) - top, 0); + MAX(_fascinWin[l].top , _fascinWin[k].top ) - top); } } } } - _vm->_video->drawSprite(*tempSrf, *_backSurface, 0, 0, width - left, height - top, left, top, 0); + _backSurface->blit(*tempSrf, 0, 0, width - left, height - top, left, top); tempSrf.reset(); } else { invalidateRect(left, top, width, height); switch (fct) { case DRAW_BLITSURF: // 0 - move - _vm->_video->drawSprite(*_spritesArray[_sourceSurface], *_backSurface, + _backSurface->blit(*_spritesArray[_sourceSurface], _spriteLeft, _spriteTop, _spriteLeft + _spriteRight - 1, _spriteTop + _spriteBottom - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); break; case DRAW_PUTPIXEL: // 1 - put a pixel - _vm->_video->putPixel(_destSpriteX, _destSpriteY, _frontColor, *_backSurface); + _backSurface->putPixel(_destSpriteX, _destSpriteY, _frontColor); break; case DRAW_FILLRECT: // 2 - fill rectangle - _vm->_video->fillRect(*_backSurface, _destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1, _backColor); + _backSurface->fillRect(_destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1, _backColor); break; case DRAW_DRAWLINE: // 3 - draw line - _vm->_video->drawLine(*_backSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); + _backSurface->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); break; case DRAW_INVALIDATE: // 4 - Draw a circle - _vm->_video->drawCircle(*_backSurface, _spriteRight, _spriteRight, _spriteRight, _frontColor); + _backSurface->drawCircle(_spriteRight, _spriteRight, _spriteRight, _frontColor); break; case DRAW_LOADSPRITE: // 5 - Uncompress and load a sprite @@ -674,42 +655,43 @@ void Draw_Fascination::drawWin(int16 fct) { case DRAW_PRINTTEXT: // 6 - Display string len = strlen(_textToPrint); for (int j = 0; j < len; j++) - _vm->_video->drawLetter(_textToPrint[j], _destSpriteX + j * _fonts[_fontIndex]->getCharWidth(), - _destSpriteY, *_fonts[_fontIndex], _transparency, _frontColor, _backColor, *_backSurface); + _fonts[_fontIndex]->drawLetter(*_backSurface, _textToPrint[j], + _destSpriteX + j * _fonts[_fontIndex]->getCharWidth(), _destSpriteY, + _frontColor, _backColor, _transparency); _destSpriteX += len * _fonts[_fontIndex]->getCharWidth(); break; case DRAW_DRAWBAR: // 7 - draw border - _vm->_video->drawLine(*_backSurface, _destSpriteX, _spriteBottom, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_backSurface, _destSpriteX, _destSpriteY, _destSpriteX, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_backSurface, _spriteRight, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_backSurface, _destSpriteX, _destSpriteY, _spriteRight, _destSpriteY, _frontColor); + _backSurface->drawLine(_destSpriteX, _spriteBottom, _spriteRight, _spriteBottom, _frontColor); + _backSurface->drawLine(_destSpriteX, _destSpriteY, _destSpriteX, _spriteBottom, _frontColor); + _backSurface->drawLine(_spriteRight, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); + _backSurface->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _destSpriteY, _frontColor); break; case DRAW_CLEARRECT: // 8 - clear rectangle if (_backColor < 16) - _vm->_video->fillRect(*_backSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); + _backSurface->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); break; case DRAW_FILLRECTABS: // 9 - fill rectangle, with other coordinates - _vm->_video->fillRect(*_backSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); + _backSurface->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); break; case DRAW_DRAWLETTER: // 10 - Display a character if (_fontToSprite[_fontIndex].sprite == -1) { if (_letterToPrint) - _vm->_video->drawLetter(_letterToPrint, _destSpriteX, _destSpriteY, *_fonts[_fontIndex], _transparency, - _frontColor, _backColor, *_spritesArray[_destSurface]); + _fonts[_fontIndex]->drawLetter(*_spritesArray[_destSurface], _letterToPrint, + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); } else { int xx, yy, nn; nn = _spritesArray[_fontToSprite[_fontIndex].sprite]->getWidth() / _fontToSprite[_fontIndex].width; yy = ((_letterToPrint - _fontToSprite[_fontIndex].base) / nn) * _fontToSprite[_fontIndex].height; xx = ((_letterToPrint - _fontToSprite[_fontIndex].base) % nn) * _fontToSprite[_fontIndex].width; - _vm->_video->drawSprite(*_spritesArray[_fontToSprite[_fontIndex].sprite], *_spritesArray[_destSurface], + _spritesArray[_destSurface]->blit(*_spritesArray[_fontToSprite[_fontIndex].sprite], xx, yy, xx + _fontToSprite[_fontIndex].width - 1, yy + _fontToSprite[_fontIndex].height - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); } break; @@ -736,7 +718,7 @@ void Draw_Fascination::drawWin(int16 fct) { } } -void Draw_Fascination::decompWin(int16 x, int16 y, SurfaceDescPtr destPtr) { +void Draw_Fascination::decompWin(int16 x, int16 y, SurfacePtr destPtr) { Resource *resource; resource = _vm->_game->_resources->getResource((uint16) _spriteLeft, &_spriteRight, &_spriteBottom); @@ -884,11 +866,11 @@ void Draw_Fascination::moveWin(int16 id) { saveWin(id); // Shift skipped as always set to zero (?) - _vm->_video->drawSprite(*_frontSurface, *_backSurface, + _backSurface->blit(*_frontSurface, oldLeft, oldTop, oldLeft + _fascinWin[id].width - 1, oldTop + _fascinWin[id].height - 1, - _fascinWin[id].left, _fascinWin[id].top, 0); + _fascinWin[id].left, _fascinWin[id].top); invalidateRect(_fascinWin[id].left, _fascinWin[id].top, _fascinWin[id].left + _fascinWin[id].width - 1, _fascinWin[id].top + _fascinWin[id].height - 1); @@ -909,8 +891,8 @@ void Draw_Fascination::activeWin(int16 id) { int16 t[10], t2[10]; int nextId = -1; int oldId = -1; - SurfaceDescPtr tempSrf; - SurfaceDescPtr oldSrf[10]; + SurfacePtr tempSrf; + SurfacePtr oldSrf[10]; if (_fascinWin[id].id == -1) return; @@ -934,11 +916,11 @@ void Draw_Fascination::activeWin(int16 id) { for (int i = 9; i >= 0; i--) { if (t[i] != -1) { if (nextId != -1) - _vm->_video->drawSprite(*_backSurface, *_fascinWin[nextId].savedSurface, + _fascinWin[nextId].savedSurface->blit(*_backSurface, _fascinWin[t[i]].left, _fascinWin[t[i]].top, _fascinWin[t[i]].left + _fascinWin[t[i]].width - 1, _fascinWin[t[i]].top + _fascinWin[t[i]].height - 1, - _fascinWin[t[i]].left & 7, 0, 0); + _fascinWin[t[i]].left & 7, 0); t2[i] = nextId; restoreWin(t[i]); nextId = t[i]; @@ -946,35 +928,35 @@ void Draw_Fascination::activeWin(int16 id) { } oldId = nextId; - _vm->_video->drawSprite(*_backSurface, *_fascinWin[nextId].savedSurface, + _fascinWin[nextId].savedSurface->blit(*_backSurface, _fascinWin[id].left, _fascinWin[id].top, _fascinWin[id].left + _fascinWin[id].width - 1, _fascinWin[id].top + _fascinWin[id].height - 1, - _fascinWin[id].left & 7, 0, 0); + _fascinWin[id].left & 7, 0); restoreWin(id); nextId = id; for (int i = 0; i < 10; i++) { if (t[i] != -1) { - _vm->_video->drawSprite(*_backSurface, *_fascinWin[nextId].savedSurface, + _fascinWin[nextId].savedSurface->blit(*_backSurface, _fascinWin[t[i]].left, _fascinWin[t[i]].top, _fascinWin[t[i]].left + _fascinWin[t[i]].width - 1, _fascinWin[t[i]].top + _fascinWin[t[i]].height - 1, - _fascinWin[t[i]].left & 7, 0, 0); + _fascinWin[t[i]].left & 7, 0); oldSrf[t[i]] = _fascinWin[nextId].savedSurface; if (t2[i] != -1) - _vm->_video->drawSprite(*_fascinWin[t2[i]].savedSurface, *_backSurface, + _backSurface->blit(*_fascinWin[t2[i]].savedSurface, _fascinWin[t[i]].left & 7, 0, (_fascinWin[t[i]].left & 7) + _fascinWin[t[i]].width - 1, _fascinWin[t[i]].height - 1, _fascinWin[t[i]].left, - _fascinWin[t[i]].top, 0); + _fascinWin[t[i]].top); else { // Shift skipped as always set to zero (?) - _vm->_video->drawSprite(*_frontSurface, *_backSurface, + _backSurface->blit(*_frontSurface, _fascinWin[t[i]].left, _fascinWin[t[i]].top, _fascinWin[t[i]].left + _fascinWin[t[i]].width - 1, _fascinWin[t[i]].top + _fascinWin[t[i]].height - 1, - _fascinWin[t[i]].left, _fascinWin[t[i]].top, 0); + _fascinWin[t[i]].left, _fascinWin[t[i]].top); } invalidateRect(_fascinWin[t[i]].left, _fascinWin[t[i]].top, _fascinWin[t[i]].left + _fascinWin[t[i]].width - 1, @@ -984,16 +966,16 @@ void Draw_Fascination::activeWin(int16 id) { } tempSrf = _vm->_video->initSurfDesc(_vm->_global->_videoMode, _winMaxWidth + 7, _winMaxHeight, 0); - _vm->_video->drawSprite(*_backSurface, *tempSrf, + tempSrf->blit(*_backSurface, _fascinWin[id].left, _fascinWin[id].top, _fascinWin[id].left + _fascinWin[id].width - 1, _fascinWin[id].top + _fascinWin[id].height - 1, - _fascinWin[id].left & 7, 0, 0); - _vm->_video->drawSprite(*_fascinWin[oldId].savedSurface, *_backSurface, + _fascinWin[id].left & 7, 0); + _backSurface->blit(*_fascinWin[oldId].savedSurface, _fascinWin[id].left & 7, 0, (_fascinWin[id].left & 7) + _fascinWin[id].width - 1, _fascinWin[id].height - 1, - _fascinWin[id].left, _fascinWin[id].top, 0); + _fascinWin[id].left, _fascinWin[id].top); _fascinWin[oldId].savedSurface.reset(); _fascinWin[oldId].savedSurface = tempSrf; @@ -1026,18 +1008,18 @@ void Draw_Fascination::closeAllWin() { } void Draw_Fascination::saveWin(int16 id) { - _vm->_video->drawSprite(*_backSurface, *_fascinWin[id].savedSurface, + _fascinWin[id].savedSurface->blit(*_backSurface, _fascinWin[id].left, _fascinWin[id].top, _fascinWin[id].left + _fascinWin[id].width - 1, _fascinWin[id].top + _fascinWin[id].height - 1, - _fascinWin[id].left & 7, 0, 0); + _fascinWin[id].left & 7, 0); } void Draw_Fascination::restoreWin(int16 id) { - _vm->_video->drawSprite(*_fascinWin[id].savedSurface, *_backSurface, + _backSurface->blit(*_fascinWin[id].savedSurface, _fascinWin[id].left & 7, 0, (_fascinWin[id].left & 7) + _fascinWin[id].width - 1, _fascinWin[id].height - 1, - _fascinWin[id].left, _fascinWin[id].top, 0); + _fascinWin[id].left, _fascinWin[id].top); invalidateRect(_fascinWin[id].left, _fascinWin[id].top, _fascinWin[id].left + _fascinWin[id].width - 1, _fascinWin[id].top + _fascinWin[id].height - 1); @@ -1049,14 +1031,19 @@ void Draw_Fascination::drawWinTrace(int16 left, int16 top, int16 width, int16 he right = left + width - 1; bottom = top + height - 1; - for (int32 x = left; x < right; x++) { - _frontSurface->getVidMem()[_frontSurface->getWidth() * top + x] = (128 + _frontSurface->getVidMem()[_frontSurface->getWidth() * top + x]) & 0xff; - _frontSurface->getVidMem()[_frontSurface->getWidth() * bottom + x] = (128 + _frontSurface->getVidMem()[_frontSurface->getWidth() * bottom + x]) & 0xff; + Pixel pixelTop = _frontSurface->get(left, top); + Pixel pixelBottom = _frontSurface->get(left, bottom); + for (int16 i = 0; i < width; i++, pixelTop++, pixelBottom++) { + pixelTop.set((pixelTop.get() + 128) & 0xFF); + pixelBottom.set((pixelBottom.get() + 128) & 0xFF); } - for (int32 y = top; y < bottom; y++) { - _frontSurface->getVidMem()[_frontSurface->getWidth() * y + left] = (128 + _frontSurface->getVidMem()[_frontSurface->getWidth() * y + left]) & 0xff; - _frontSurface->getVidMem()[_frontSurface->getWidth() * y + right] = (128 + _frontSurface->getVidMem()[_frontSurface->getWidth() * y + right]) & 0xff; + Pixel pixelLeft = _frontSurface->get(left, top); + Pixel pixelRight = _frontSurface->get(right, top); + + for (int16 i = 0; i < height; i++, pixelLeft += _frontSurface->getWidth(), pixelRight += _frontSurface->getWidth()) { + pixelLeft.set((pixelLeft.get() + 128) & 0xFF); + pixelRight.set((pixelRight.get() + 128) & 0xFF); } _vm->_video->dirtyRectsAll(); diff --git a/engines/gob/draw_playtoons.cpp b/engines/gob/draw_playtoons.cpp index 583d13986e..8d8f040924 100644 --- a/engines/gob/draw_playtoons.cpp +++ b/engines/gob/draw_playtoons.cpp @@ -38,7 +38,7 @@ Draw_Playtoons::Draw_Playtoons(GobEngine *vm) : Draw_v2(vm) { void Draw_Playtoons::spriteOperation(int16 operation) { int16 len; int16 x, y; - SurfaceDescPtr sourceSurf, destSurf; + SurfacePtr sourceSurf, destSurf; bool deltaVeto; int16 left; int16 ratio; @@ -139,12 +139,11 @@ void Draw_Playtoons::spriteOperation(int16 operation) { if (!sourceSurf || !destSurf) break; - _vm->_video->drawSprite(*_spritesArray[_sourceSurface], - *_spritesArray[_destSurface], + _spritesArray[_destSurface]->blit(*_spritesArray[_sourceSurface], _spriteLeft, spriteTop, _spriteLeft + _spriteRight - 1, _spriteTop + _spriteBottom - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1); @@ -156,22 +155,22 @@ void Draw_Playtoons::spriteOperation(int16 operation) { warning("oPlaytoons_spriteOperation: operation DRAW_PUTPIXEL, pattern -1"); break; case 1: - _vm->_video->fillRect(*_spritesArray[_destSurface], destSpriteX, + _spritesArray[_destSurface]->fillRect(destSpriteX, _destSpriteY, _destSpriteX + 1, _destSpriteY + 1, _frontColor); break; case 2: - _vm->_video->fillRect(*_spritesArray[_destSurface], destSpriteX - 1, + _spritesArray[_destSurface]->fillRect(destSpriteX - 1, _destSpriteY - 1, _destSpriteX + 1, _destSpriteY + 1, _frontColor); break; case 3: - _vm->_video->fillRect(*_spritesArray[_destSurface], destSpriteX - 1, + _spritesArray[_destSurface]->fillRect(destSpriteX - 1, _destSpriteY - 1, _destSpriteX + 2, _destSpriteY + 2, _frontColor); break; default: - _vm->_video->putPixel(_destSpriteX, _destSpriteY, _frontColor, *_spritesArray[_destSurface]); + _spritesArray[_destSurface]->putPixel(_destSpriteX, _destSpriteY, _frontColor); break; } dirtiedRect(_destSurface, _destSpriteX - (_pattern / 2), @@ -188,7 +187,7 @@ void Draw_Playtoons::spriteOperation(int16 operation) { warning("oPlaytoons_spriteOperation: operation DRAW_FILLRECT, pattern %d", _pattern & 0xFF); break; case 0: - _vm->_video->fillRect(*_spritesArray[_destSurface], destSpriteX, + _spritesArray[_destSurface]->fillRect(destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1, _backColor); @@ -204,23 +203,18 @@ void Draw_Playtoons::spriteOperation(int16 operation) { case DRAW_DRAWLINE: if ((_needAdjust != 2) && (_needAdjust < 10)) { warning ("oPlaytoons_spriteOperation: operation DRAW_DRAWLINE, draw multiple lines"); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX + 1, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX + 1, _destSpriteY, _spriteRight + 1, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY + 1, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY + 1, _spriteRight, _spriteBottom + 1, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX + 1, _destSpriteY + 1, + _spritesArray[_destSurface]->drawLine(_destSpriteX + 1, _destSpriteY + 1, _spriteRight + 1, _spriteBottom + 1, _frontColor); } else { switch (_pattern & 0xFF) { case 0: - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); break; @@ -228,7 +222,7 @@ void Draw_Playtoons::spriteOperation(int16 operation) { warning("oPlaytoons_spriteOperation: operation DRAW_DRAWLINE, draw %d lines", (_pattern & 0xFF) * (_pattern & 0xFF)); for (int16 i = 0; i <= _pattern ; i++) for (int16 j = 0; j <= _pattern ; j++) - _vm->_video->drawLine(*_spritesArray[_destSurface], + _spritesArray[_destSurface]->drawLine( _destSpriteX - (_pattern / 2) + i, _destSpriteY - (_pattern / 2) + j, _spriteRight - (_pattern / 2) + i, @@ -247,7 +241,7 @@ void Draw_Playtoons::spriteOperation(int16 operation) { if ((_pattern & 0xFF) != 0) warning("oPlaytoons_spriteOperation: operation DRAW_INVALIDATE, pattern %d", _pattern & 0xFF); - _vm->_video->drawCircle(*_spritesArray[_destSurface], _destSpriteX, + _spritesArray[_destSurface]->drawCircle(_destSpriteX, _destSpriteY, _spriteRight, _frontColor); dirtiedRect(_destSurface, _destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, @@ -289,9 +283,8 @@ void Draw_Playtoons::spriteOperation(int16 operation) { byte *dataBuf = _vm->_game->_resources->getTexts() + _textToPrint[1] + 1; len = *dataBuf++; for (int i = 0; i < len; i++, dataBuf += 2) { - _vm->_video->drawLetter(READ_LE_UINT16(dataBuf), _destSpriteX, - _destSpriteY, *font, _transparency, _frontColor, - _backColor, *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], READ_LE_UINT16(dataBuf), + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); } } else { drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor, @@ -300,9 +293,8 @@ void Draw_Playtoons::spriteOperation(int16 operation) { } } else { for (int i = 0; i < len; i++) { - _vm->_video->drawLetter(_textToPrint[i], _destSpriteX, - _destSpriteY, *font, _transparency, - _frontColor, _backColor, *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], _textToPrint[i], + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); _destSpriteX += font->getCharWidth(_textToPrint[i]); } } @@ -317,11 +309,10 @@ void Draw_Playtoons::spriteOperation(int16 operation) { * _fontToSprite[_fontIndex].height; x = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) % ratio) * _fontToSprite[_fontIndex].width; - _vm->_video->drawSprite(*_spritesArray[_fontToSprite[_fontIndex].sprite], - *_spritesArray[_destSurface], x, y, + _spritesArray[_destSurface]->blit(*_spritesArray[_fontToSprite[_fontIndex].sprite], x, y, x + _fontToSprite[_fontIndex].width - 1, y + _fontToSprite[_fontIndex].height - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); _destSpriteX += _fontToSprite[_fontIndex].width; } } @@ -332,36 +323,28 @@ void Draw_Playtoons::spriteOperation(int16 operation) { case DRAW_DRAWBAR: if ((_needAdjust != 2) && (_needAdjust < 10)){ - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _spriteBottom - 1, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _spriteBottom - 1, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _destSpriteX + 1, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _spriteRight - 1, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_spriteRight - 1, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _destSpriteY + 1, _frontColor); } else { - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _spriteBottom, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _spriteBottom, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _destSpriteX, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _spriteRight, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_spriteRight, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _destSpriteY, _frontColor); } @@ -371,8 +354,7 @@ void Draw_Playtoons::spriteOperation(int16 operation) { case DRAW_CLEARRECT: warning ("oPlaytoons_spriteOperation: DRAW_CLEARRECT uses _backColor %d", _backColor); if (_backColor != -1) { - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); } @@ -381,8 +363,7 @@ void Draw_Playtoons::spriteOperation(int16 operation) { break; case DRAW_FILLRECTABS: - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); diff --git a/engines/gob/draw_v1.cpp b/engines/gob/draw_v1.cpp index 1cec15ce04..f768ca29c2 100644 --- a/engines/gob/draw_v1.cpp +++ b/engines/gob/draw_v1.cpp @@ -119,12 +119,12 @@ void Draw_v1::animateCursor(int16 cursor) { newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar); } - _vm->_video->clearSurf(*_scummvmCursor); - _vm->_video->drawSprite(*_cursorSprites, *_scummvmCursor, + _scummvmCursor->clear(); + _scummvmCursor->blit(*_cursorSprites, cursorIndex * _cursorWidth, 0, (cursorIndex + 1) * _cursorWidth - 1, - _cursorHeight - 1, 0, 0, 0); - CursorMan.replaceCursor(_scummvmCursor->getVidMem(), + _cursorHeight - 1, 0, 0); + CursorMan.replaceCursor(_scummvmCursor->getData(), _cursorWidth, _cursorHeight, hotspotX, hotspotY, 0); if (_frontSurface != _backSurface) { @@ -346,27 +346,24 @@ void Draw_v1::spriteOperation(int16 operation) { Font *font = 0; switch (operation) { case DRAW_BLITSURF: - _vm->_video->drawSprite(*_spritesArray[_sourceSurface], - *_spritesArray[_destSurface], + _spritesArray[_destSurface]->blit(*_spritesArray[_sourceSurface], _spriteLeft, _spriteTop, _spriteLeft + _spriteRight - 1, _spriteTop + _spriteBottom - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1); break; case DRAW_PUTPIXEL: - _vm->_video->putPixel(_destSpriteX, _destSpriteY, - _frontColor, *_spritesArray[_destSurface]); + _spritesArray[_destSurface]->putPixel(_destSpriteX, _destSpriteY, _frontColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX, _destSpriteY); break; case DRAW_FILLRECT: - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1, _backColor); @@ -375,8 +372,7 @@ void Draw_v1::spriteOperation(int16 operation) { break; case DRAW_DRAWLINE: - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); @@ -417,31 +413,24 @@ void Draw_v1::spriteOperation(int16 operation) { _destSpriteY + font->getCharHeight() - 1); for (int i = 0; i < len; i++) { - _vm->_video->drawLetter(_textToPrint[i], - _destSpriteX, _destSpriteY, - *font, _transparency, - _frontColor, _backColor, - *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], _textToPrint[i], + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); _destSpriteX += font->getCharWidth(); } break; case DRAW_DRAWBAR: - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _spriteBottom, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _spriteBottom, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _destSpriteX, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _spriteRight, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_spriteRight, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _destSpriteY, _frontColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); @@ -449,8 +438,7 @@ void Draw_v1::spriteOperation(int16 operation) { case DRAW_CLEARRECT: if (_backColor < 16) { - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); } @@ -458,8 +446,7 @@ void Draw_v1::spriteOperation(int16 operation) { break; case DRAW_FILLRECTABS: - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); @@ -476,11 +463,8 @@ void Draw_v1::spriteOperation(int16 operation) { dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX + font->getCharWidth() - 1, _destSpriteY + font->getCharHeight() - 1); - _vm->_video->drawLetter(_letterToPrint, - _destSpriteX, _destSpriteY, - *font, _transparency, - _frontColor, _backColor, - *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], _letterToPrint, + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); break; } @@ -498,11 +482,10 @@ void Draw_v1::spriteOperation(int16 operation) { _destSpriteX + _fontToSprite[_fontIndex].width, _destSpriteY + _fontToSprite[_fontIndex].height); - _vm->_video->drawSprite(*_spritesArray[(int16)_fontToSprite[_fontIndex].sprite], - *_spritesArray[_destSurface], x, y, + _spritesArray[_destSurface]->blit(*_spritesArray[(int16)_fontToSprite[_fontIndex].sprite], x, y, x + _fontToSprite[_fontIndex].width, y + _fontToSprite[_fontIndex].height, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); break; } diff --git a/engines/gob/draw_v2.cpp b/engines/gob/draw_v2.cpp index 4ecb759e9d..bc39ce2018 100644 --- a/engines/gob/draw_v2.cpp +++ b/engines/gob/draw_v2.cpp @@ -53,7 +53,7 @@ void Draw_v2::initScreen() { initSpriteSurf(kBackSurface, _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0); _backSurface = _spritesArray[kBackSurface]; - _vm->_video->clearSurf(*_backSurface); + _backSurface->clear(); if (!_spritesArray[kCursorSurface]) { initSpriteSurf(kCursorSurface, 32, 16, 2); @@ -144,12 +144,12 @@ void Draw_v2::animateCursor(int16 cursor) { newY -= hotspotY = (uint16) VAR(_cursorIndex + _cursorHotspotYVar); } - _vm->_video->clearSurf(*_scummvmCursor); - _vm->_video->drawSprite(*_cursorSprites, *_scummvmCursor, + _scummvmCursor->clear(); + _scummvmCursor->blit(*_cursorSprites, cursorIndex * _cursorWidth, 0, (cursorIndex + 1) * _cursorWidth - 1, - _cursorHeight - 1, 0, 0, 0); - CursorMan.replaceCursor(_scummvmCursor->getVidMem(), + _cursorHeight - 1, 0, 0); + CursorMan.replaceCursor(_scummvmCursor->getData(), _cursorWidth, _cursorHeight, hotspotX, hotspotY, 0); if (_frontSurface != _backSurface) { @@ -617,7 +617,7 @@ void Draw_v2::printTotText(int16 id) { void Draw_v2::spriteOperation(int16 operation) { int16 len; int16 x, y; - SurfaceDescPtr sourceSurf, destSurf; + SurfacePtr sourceSurf, destSurf; bool deltaVeto; int16 left; int16 ratio; @@ -718,26 +718,24 @@ void Draw_v2::spriteOperation(int16 operation) { if (!sourceSurf || !destSurf) break; - _vm->_video->drawSprite(*_spritesArray[_sourceSurface], - *_spritesArray[_destSurface], + _spritesArray[_destSurface]->blit(*_spritesArray[_sourceSurface], _spriteLeft, spriteTop, _spriteLeft + _spriteRight - 1, _spriteTop + _spriteBottom - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1); break; case DRAW_PUTPIXEL: - _vm->_video->putPixel(_destSpriteX, _destSpriteY, _frontColor, - *_spritesArray[_destSurface]); + _spritesArray[_destSurface]->putPixel(_destSpriteX, _destSpriteY, _frontColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _destSpriteX, _destSpriteY); break; case DRAW_FILLRECT: - _vm->_video->fillRect(*_spritesArray[_destSurface], destSpriteX, + _spritesArray[_destSurface]->fillRect(destSpriteX, _destSpriteY, _destSpriteX + _spriteRight - 1, _destSpriteY + _spriteBottom - 1, _backColor); @@ -746,15 +744,14 @@ void Draw_v2::spriteOperation(int16 operation) { break; case DRAW_DRAWLINE: - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); break; case DRAW_INVALIDATE: - _vm->_video->drawCircle(*_spritesArray[_destSurface], _destSpriteX, + _spritesArray[_destSurface]->drawCircle(_destSpriteX, _destSpriteY, _spriteRight, _frontColor); dirtiedRect(_destSurface, _destSpriteX - _spriteRight, _destSpriteY - _spriteBottom, @@ -796,9 +793,8 @@ void Draw_v2::spriteOperation(int16 operation) { byte *dataBuf = _vm->_game->_resources->getTexts() + _textToPrint[1] + 1; len = *dataBuf++; for (int i = 0; i < len; i++, dataBuf += 2) { - _vm->_video->drawLetter(READ_LE_UINT16(dataBuf), _destSpriteX, - _destSpriteY, *font, _transparency, _frontColor, - _backColor, *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], READ_LE_UINT16(dataBuf), + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); } } else { drawString(_textToPrint, _destSpriteX, _destSpriteY, _frontColor, @@ -807,9 +803,8 @@ void Draw_v2::spriteOperation(int16 operation) { } } else { for (int i = 0; i < len; i++) { - _vm->_video->drawLetter(_textToPrint[i], _destSpriteX, - _destSpriteY, *font, _transparency, - _frontColor, _backColor, *_spritesArray[_destSurface]); + font->drawLetter(*_spritesArray[_destSurface], _textToPrint[i], + _destSpriteX, _destSpriteY, _frontColor, _backColor, _transparency); _destSpriteX += font->getCharWidth(_textToPrint[i]); } } @@ -824,11 +819,10 @@ void Draw_v2::spriteOperation(int16 operation) { * _fontToSprite[_fontIndex].height; x = ((_textToPrint[i] - _fontToSprite[_fontIndex].base) % ratio) * _fontToSprite[_fontIndex].width; - _vm->_video->drawSprite(*_spritesArray[_fontToSprite[_fontIndex].sprite], - *_spritesArray[_destSurface], x, y, + _spritesArray[_destSurface]->blit(*_spritesArray[_fontToSprite[_fontIndex].sprite], x, y, x + _fontToSprite[_fontIndex].width - 1, y + _fontToSprite[_fontIndex].height - 1, - _destSpriteX, _destSpriteY, _transparency); + _destSpriteX, _destSpriteY, (_transparency == 0) ? -1 : 0); _destSpriteX += _fontToSprite[_fontIndex].width; } } @@ -839,36 +833,28 @@ void Draw_v2::spriteOperation(int16 operation) { case DRAW_DRAWBAR: if (_needAdjust != 2) { - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _spriteBottom - 1, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _spriteBottom - 1, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _destSpriteX + 1, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _spriteRight - 1, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_spriteRight - 1, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _destSpriteY + 1, _frontColor); } else { - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _spriteBottom, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _spriteBottom, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _destSpriteX, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _spriteRight, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_spriteRight, _destSpriteY, _spriteRight, _spriteBottom, _frontColor); - _vm->_video->drawLine(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->drawLine(_destSpriteX, _destSpriteY, _spriteRight, _destSpriteY, _frontColor); } @@ -877,8 +863,7 @@ void Draw_v2::spriteOperation(int16 operation) { case DRAW_CLEARRECT: if ((_backColor != 16) && (_backColor != 144)) { - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); } @@ -887,8 +872,7 @@ void Draw_v2::spriteOperation(int16 operation) { break; case DRAW_FILLRECTABS: - _vm->_video->fillRect(*_spritesArray[_destSurface], - _destSpriteX, _destSpriteY, + _spritesArray[_destSurface]->fillRect(_destSpriteX, _destSpriteY, _spriteRight, _spriteBottom, _backColor); dirtiedRect(_destSurface, _destSpriteX, _destSpriteY, _spriteRight, _spriteBottom); diff --git a/engines/gob/driver_vga.cpp b/engines/gob/driver_vga.cpp index 7be1daf9f3..1c43b2640a 100644 --- a/engines/gob/driver_vga.cpp +++ b/engines/gob/driver_vga.cpp @@ -30,28 +30,30 @@ namespace Gob { +/* static void plotPixel(int x, int y, int color, void *data) { - SurfaceDesc *dest = (SurfaceDesc *)data; + Surface *dest = (Surface *)data; if ((x >= 0) && (x < dest->getWidth()) && (y >= 0) && (y < dest->getHeight())) dest->getVidMem()[(y * dest->getWidth()) + x] = color; } +*/ -void VGAVideoDriver::putPixel(int16 x, int16 y, byte color, SurfaceDesc &dest) { +void VGAVideoDriver::putPixel(int16 x, int16 y, byte color, Surface &dest) { /* if ((x >= 0) && (x < dest.getWidth()) && (y >= 0) && (y < dest.getHeight())) dest.getVidMem()[(y * dest.getWidth()) + x] = color; -} +*/ } -void VGAVideoDriver::drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1, - int16 y1, byte color) { +void VGAVideoDriver::drawLine(Surface &dest, int16 x0, int16 y0, int16 x1, + int16 y1, byte color) { /* Graphics::drawLine(x0, y0, x1, y1, color, &plotPixel, &dest); -} +*/ } -void VGAVideoDriver::fillRect(SurfaceDesc &dest, int16 left, int16 top, - int16 right, int16 bottom, byte color) { +void VGAVideoDriver::fillRect(Surface &dest, int16 left, int16 top, + int16 right, int16 bottom, byte color) { /* if ((left >= dest.getWidth()) || (right >= dest.getWidth()) || (top >= dest.getHeight()) || (bottom >= dest.getHeight())) @@ -67,11 +69,11 @@ void VGAVideoDriver::fillRect(SurfaceDesc &dest, int16 left, int16 top, pos += dest.getWidth(); } -} +*/ } void VGAVideoDriver::drawLetter(unsigned char item, int16 x, int16 y, const Font &font, byte color1, byte color2, - byte transp, SurfaceDesc &dest) { + byte transp, Surface &dest) { /* uint16 data; const byte *src = font.getCharData(item); @@ -116,11 +118,11 @@ void VGAVideoDriver::drawLetter(unsigned char item, int16 x, int16 y, dst += dest.getWidth() - font.getCharWidth(); } -} +*/ } -void VGAVideoDriver::drawSprite(SurfaceDesc &source, SurfaceDesc &dest, +void VGAVideoDriver::drawSprite(Surface &source, Surface &dest, int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y, int16 transp) { + int16 x, int16 y, int16 transp) { /* if ((x >= dest.getWidth()) || (x < 0) || (y >= dest.getHeight()) || (y < 0)) @@ -169,11 +171,11 @@ void VGAVideoDriver::drawSprite(SurfaceDesc &source, SurfaceDesc &dest, } } -} +*/ } -void VGAVideoDriver::drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, +void VGAVideoDriver::drawSpriteDouble(Surface &source, Surface &dest, int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y, int16 transp) { + int16 x, int16 y, int16 transp) { /* if ((x >= dest.getWidth()) || (x < 0) || (y >= dest.getHeight()) || (y < 0)) @@ -206,10 +208,10 @@ void VGAVideoDriver::drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, srcPos = srcBak + source.getWidth(); } -} +*/ } void VGAVideoDriver::drawPackedSprite(byte *sprBuf, int16 width, int16 height, - int16 x, int16 y, byte transp, SurfaceDesc &dest) { + int16 x, int16 y, byte transp, Surface &dest) { /* int destRight = x + width; int destBottom = y + height; @@ -248,7 +250,7 @@ void VGAVideoDriver::drawPackedSprite(byte *sprBuf, int16 width, int16 height, } -} +*/ } } diff --git a/engines/gob/driver_vga.h b/engines/gob/driver_vga.h index 3102016cb5..18a2e252cb 100644 --- a/engines/gob/driver_vga.h +++ b/engines/gob/driver_vga.h @@ -35,20 +35,20 @@ public: VGAVideoDriver() {} virtual ~VGAVideoDriver() {} - void putPixel(int16 x, int16 y, byte color, SurfaceDesc &dest); - void drawLine(SurfaceDesc &dest, int16 x0, int16 y0, + void putPixel(int16 x, int16 y, byte color, Surface &dest); + void drawLine(Surface &dest, int16 x0, int16 y0, int16 x1, int16 y1, byte color); - void fillRect(SurfaceDesc &dest, int16 left, int16 top, + void fillRect(Surface &dest, int16 left, int16 top, int16 right, int16 bottom, byte color); void drawLetter(unsigned char item, int16 x, int16 y, const Font &font, byte color1, byte color2, - byte transp, SurfaceDesc &dest); - void drawSprite(SurfaceDesc &source, SurfaceDesc &dest, int16 left, + byte transp, Surface &dest); + void drawSprite(Surface &source, Surface &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp); - void drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, int16 left, + void drawSpriteDouble(Surface &source, Surface &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp); void drawPackedSprite(byte *sprBuf, int16 width, int16 height, - int16 x, int16 y, byte transp, SurfaceDesc &dest); + int16 x, int16 y, byte transp, Surface &dest); }; } diff --git a/engines/gob/game.cpp b/engines/gob/game.cpp index b5025ba76f..f77b3e946a 100644 --- a/engines/gob/game.cpp +++ b/engines/gob/game.cpp @@ -214,7 +214,7 @@ void Game::prepareStart() { _vm->_video->setFullPalette(_vm->_global->_pPaletteDesc); _vm->_draw->initScreen(); - _vm->_video->fillRect(*_vm->_draw->_frontSurface, 0, 0, + _vm->_draw->_frontSurface->fillRect(0, 0, _vm->_video->_surfWidth - 1, _vm->_video->_surfHeight - 1, 1); _vm->_util->setMousePos(152, 92); diff --git a/engines/gob/global.h b/engines/gob/global.h index 4fce5952eb..713b501f35 100644 --- a/engines/gob/global.h +++ b/engines/gob/global.h @@ -127,7 +127,7 @@ public: bool _setAllPalette; bool _dontSetPalette; - SurfaceDescPtr _primarySurfDesc; + SurfacePtr _primarySurfDesc; int16 _debugFlag; int16 _inVM; diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp index 9ca773c18f..63625acbd9 100644 --- a/engines/gob/gob.cpp +++ b/engines/gob/gob.cpp @@ -580,7 +580,7 @@ bool GobEngine::initGraphics() { _global->_mouseMaxX = _width; _global->_mouseMaxY = _height; - _global->_primarySurfDesc = SurfaceDescPtr(new SurfaceDesc(_mode, _width, _height)); + _global->_primarySurfDesc = SurfacePtr(new Surface(_width, _height, 1)); return true; } diff --git a/engines/gob/goblin.cpp b/engines/gob/goblin.cpp index 11043df782..ee2b4f52c9 100644 --- a/engines/gob/goblin.cpp +++ b/engines/gob/goblin.cpp @@ -233,9 +233,9 @@ void Goblin::drawObjects() { if (objDesc->toRedraw == 0) continue; - _vm->_video->drawSprite(*_vm->_mult->_animSurf, *_vm->_draw->_backSurface, + _vm->_draw->_backSurface->blit(*_vm->_mult->_animSurf, objDesc->left, objDesc->top, objDesc->right, - objDesc->bottom, objDesc->left, objDesc->top, 0); + objDesc->bottom, objDesc->left, objDesc->top); _vm->_draw->invalidateRect(objDesc->left, objDesc->top, objDesc->right, objDesc->bottom); diff --git a/engines/gob/hotspots.cpp b/engines/gob/hotspots.cpp index 78b3553aeb..881481a341 100644 --- a/engines/gob/hotspots.cpp +++ b/engines/gob/hotspots.cpp @@ -1236,18 +1236,18 @@ void Hotspots::evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs, _vm->_draw->_invalidatedBottoms[0] = 199; _vm->_draw->_invalidatedCount = 1; if (windowNum == 0) { - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left + width - 1, top, left + width - 1, top + height - 1, 0); - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left, top + height - 1, 0); - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left + width - 1, top, 0); - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top + height - 1, left + width - 1, top + height - 1, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left + width - 1, top, left + width - 1, top + height - 1, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left, top + height - 1, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left + width - 1, top, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top + height - 1, left + width - 1, top + height - 1, 0); } else { if ((_vm->_draw->_fascinWin[windowNum].id != -1) && (_vm->_draw->_fascinWin[windowNum].id == _vm->_draw->_winCount - 1)) { left += _vm->_draw->_fascinWin[windowNum].left; top += _vm->_draw->_fascinWin[windowNum].top; - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left + width - 1, top, left + width - 1, top + height - 1, 0); - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left, top + height - 1, 0); - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top, left + width - 1, top, 0); - _vm->_video->drawLine(*_vm->_draw->_spritesArray[_vm->_draw->_destSurface], left, top + height - 1, left + width - 1, top + height - 1, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left + width - 1, top, left + width - 1, top + height - 1, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left, top + height - 1, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top, left + width - 1, top, 0); + _vm->_draw->_spritesArray[_vm->_draw->_destSurface]->drawLine(left, top + height - 1, left + width - 1, top + height - 1, 0); left -= _vm->_draw->_fascinWin[windowNum].left; top -= _vm->_draw->_fascinWin[windowNum].top; } diff --git a/engines/gob/inter_bargon.cpp b/engines/gob/inter_bargon.cpp index 5c56196641..3afb70d6c0 100644 --- a/engines/gob/inter_bargon.cpp +++ b/engines/gob/inter_bargon.cpp @@ -120,16 +120,16 @@ void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) { int16 mouseX; int16 mouseY; MouseButtons buttons; - SurfaceDescPtr surface; + SurfacePtr surface; SoundDesc samples[4]; int16 comp[5] = { 0, 1, 2, 3, -1 }; static const char *sndFiles[] = {"1INTROII.snd", "2INTROII.snd", "1INTRO3.snd", "2INTRO3.snd"}; surface = _vm->_video->initSurfDesc(_vm->_global->_videoMode, 320, 200, 0); _vm->_video->drawPackedSprite("2ille.ims", *surface); - _vm->_video->drawSprite(*surface, *_vm->_draw->_frontSurface, 0, 0, 319, 199, 0, 0, 0); + _vm->_draw->_frontSurface->blit(*surface, 0, 0, 319, 199, 0, 0); _vm->_video->drawPackedSprite("2ille4.ims", *surface); - _vm->_video->drawSprite(*surface, *_vm->_draw->_frontSurface, 0, 0, 319, 199, 320, 0, 0); + _vm->_draw->_frontSurface->blit(*surface, 0, 0, 319, 199, 320, 0); _vm->_util->setScrollOffset(320, 0); _vm->_video->dirtyRectsAll(); _vm->_palAnim->fade(_vm->_global->_pPaletteDesc, -2, 0); @@ -140,7 +140,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) { if ((_vm->_game->checkKeys(&mouseX, &mouseY, &buttons, 0) == kKeyEscape) || _vm->shouldQuit()) { _vm->_palAnim->fade(0, -2, 0); - _vm->_video->clearSurf(*_vm->_draw->_frontSurface); + _vm->_draw->_frontSurface->clear(); memset((char *)_vm->_draw->_vgaPalette, 0, 768); WRITE_VAR(4, buttons); WRITE_VAR(0, kKeyEscape); @@ -161,7 +161,7 @@ void Inter_Bargon::oBargon_intro2(OpGobParams ¶ms) { _vm->_sound->blasterPlayComposition(comp, 0, samples, 4); _vm->_sound->blasterWaitEndPlay(true, false); _vm->_palAnim->fade(0, 0, 0); - _vm->_video->clearSurf(*_vm->_draw->_frontSurface); + _vm->_draw->_frontSurface->clear(); } void Inter_Bargon::oBargon_intro3(OpGobParams ¶ms) { @@ -192,7 +192,7 @@ void Inter_Bargon::oBargon_intro3(OpGobParams ¶ms) { _vm->shouldQuit()) { _vm->_sound->blasterStop(10); _vm->_palAnim->fade(0, -2, 0); - _vm->_video->clearSurf(*_vm->_draw->_frontSurface); + _vm->_draw->_frontSurface->clear(); memset(_vm->_draw->_vgaPalette, 0, 768); WRITE_VAR(4, buttons); WRITE_VAR(0, kKeyEscape); diff --git a/engines/gob/inter_v1.cpp b/engines/gob/inter_v1.cpp index 11fe0c9c5e..3bf7fc8fd4 100644 --- a/engines/gob/inter_v1.cpp +++ b/engines/gob/inter_v1.cpp @@ -492,10 +492,10 @@ void Inter_v1::o1_initMult() { _vm->_mult->_animSurf = _vm->_draw->_spritesArray[Draw::kAnimSurface]; } - _vm->_video->drawSprite(*_vm->_draw->_backSurface, *_vm->_mult->_animSurf, + _vm->_mult->_animSurf->blit(*_vm->_draw->_backSurface, _vm->_mult->_animLeft, _vm->_mult->_animTop, _vm->_mult->_animLeft + _vm->_mult->_animWidth - 1, - _vm->_mult->_animTop + _vm->_mult->_animHeight - 1, 0, 0, 0); + _vm->_mult->_animTop + _vm->_mult->_animHeight - 1, 0, 0); debugC(4, kDebugGraphics, "o1_initMult: x = %d, y = %d, w = %d, h = %d", _vm->_mult->_animLeft, _vm->_mult->_animTop, @@ -707,8 +707,7 @@ bool Inter_v1::o1_loadCursor(OpFuncParams ¶ms) { if (!resource) return false; - _vm->_video->fillRect(*_vm->_draw->_cursorSprites, - index * _vm->_draw->_cursorWidth, 0, + _vm->_draw->_cursorSprites->fillRect(index * _vm->_draw->_cursorWidth, 0, index * _vm->_draw->_cursorWidth + _vm->_draw->_cursorWidth - 1, _vm->_draw->_cursorHeight - 1, 0); @@ -1075,7 +1074,7 @@ bool Inter_v1::o1_palLoad(OpFuncParams ¶ms) { } } if (!allZero) { - _vm->_video->clearSurf(*_vm->_draw->_frontSurface); + _vm->_draw->_frontSurface->clear(); _vm->_draw->_noInvalidated57 = true; _vm->_game->_script->skip(48); return false; @@ -1190,6 +1189,9 @@ bool Inter_v1::o1_keyFunc(OpFuncParams ¶ms) { int16 key; uint32 now; + _vm->_draw->forceBlit(); + _vm->_video->retrace(); + cmd = _vm->_game->_script->readInt16(); animPalette(); _vm->_draw->blitInvalidated(); diff --git a/engines/gob/inter_v4.cpp b/engines/gob/inter_v4.cpp index ce1f19e9a7..b47691b40f 100644 --- a/engines/gob/inter_v4.cpp +++ b/engines/gob/inter_v4.cpp @@ -134,8 +134,8 @@ void Inter_v4::o4_initScreen() { _vm->_util->setScrollOffset(); if (offY > 0) { - _vm->_draw->_spritesArray[24] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY)); - _vm->_draw->_spritesArray[25] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY)); + _vm->_draw->_spritesArray[24] = SurfacePtr(new Surface(_vm->_width, offY, 1)); + _vm->_draw->_spritesArray[25] = SurfacePtr(new Surface(_vm->_width, offY, 1)); _vm->_video->_splitSurf = _vm->_draw->_spritesArray[25]; } } diff --git a/engines/gob/inter_v5.cpp b/engines/gob/inter_v5.cpp index b6cfe0ea3c..4106aef612 100644 --- a/engines/gob/inter_v5.cpp +++ b/engines/gob/inter_v5.cpp @@ -194,8 +194,8 @@ void Inter_v5::o5_initScreen() { _vm->_util->setScrollOffset(); if (offY > 0) { - _vm->_draw->_spritesArray[24] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY)); - _vm->_draw->_spritesArray[25] = SurfaceDescPtr(new SurfaceDesc(videoMode, _vm->_width, offY)); + _vm->_draw->_spritesArray[24] = SurfacePtr(new Surface(_vm->_width, offY, 1)); + _vm->_draw->_spritesArray[25] = SurfacePtr(new Surface(_vm->_width, offY, 1)); _vm->_video->_splitSurf = _vm->_draw->_spritesArray[25]; } } diff --git a/engines/gob/inter_v6.cpp b/engines/gob/inter_v6.cpp index fc81de757e..c6d0211c8f 100644 --- a/engines/gob/inter_v6.cpp +++ b/engines/gob/inter_v6.cpp @@ -238,7 +238,7 @@ bool Inter_v6::o6_loadCursor(OpFuncParams ¶ms) { props.lastFrame = i; _vm->_vidPlayer->play(vmdSlot, props); - _vm->_vidPlayer->copyFrame(vmdSlot, _vm->_draw->_cursorSprites->getVidMem(), + _vm->_vidPlayer->copyFrame(vmdSlot, _vm->_draw->_cursorSprites->getData(), 0, 0, _vm->_draw->_cursorWidth, _vm->_draw->_cursorWidth, (start + i) * _vm->_draw->_cursorWidth, 0, _vm->_draw->_cursorSprites->getWidth()); @@ -262,8 +262,7 @@ bool Inter_v6::o6_loadCursor(OpFuncParams ¶ms) { if (!resource) return false; - _vm->_video->fillRect(*_vm->_draw->_cursorSprites, - index * _vm->_draw->_cursorWidth, 0, + _vm->_draw->_cursorSprites->fillRect(index * _vm->_draw->_cursorWidth, 0, index * _vm->_draw->_cursorWidth + _vm->_draw->_cursorWidth - 1, _vm->_draw->_cursorHeight - 1, 0); diff --git a/engines/gob/mult.h b/engines/gob/mult.h index 7766508922..fc83e2dbe3 100644 --- a/engines/gob/mult.h +++ b/engines/gob/mult.h @@ -232,7 +232,7 @@ public: int8 *_orderArray; - SurfaceDescPtr _animSurf; + SurfacePtr _animSurf; int16 _animLeft; int16 _animTop; int16 _animWidth; diff --git a/engines/gob/mult_v1.cpp b/engines/gob/mult_v1.cpp index 84869066e1..4be0a49b45 100644 --- a/engines/gob/mult_v1.cpp +++ b/engines/gob/mult_v1.cpp @@ -320,8 +320,7 @@ void Mult_v1::playMultInit() { 320, 200, 0); _vm->_draw->_spritesArray[Draw::kAnimSurface] = _animSurf; - _vm->_video->drawSprite(*_vm->_draw->_backSurface, - *_animSurf, 0, 0, 319, 199, 0, 0, 0); + _animSurf->blit(*_vm->_draw->_backSurface, 0, 0, 319, 199, 0, 0); _animDataAllocated = true; } else @@ -350,8 +349,7 @@ void Mult_v1::drawStatics(bool &stop) { _vm->_scenery->_curStatic = _multData->staticIndices[_vm->_scenery->_curStatic]; _vm->_scenery->renderStatic(_vm->_scenery->_curStatic, _vm->_scenery->_curStaticLayer); - _vm->_video->drawSprite(*_vm->_draw->_backSurface, *_animSurf, - 0, 0, 319, 199, 0, 0, 0); + _animSurf->blit(*_vm->_draw->_backSurface, 0, 0, 319, 199, 0, 0); } } diff --git a/engines/gob/mult_v2.cpp b/engines/gob/mult_v2.cpp index ab513d78bb..4da53097fc 100644 --- a/engines/gob/mult_v2.cpp +++ b/engines/gob/mult_v2.cpp @@ -582,9 +582,8 @@ void Mult_v2::playMultInit() { _vm->_draw->initSpriteSurf(Draw::kAnimSurface, width, height, 0); _animSurf = _vm->_draw->_spritesArray[Draw::kAnimSurface]; - _vm->_video->drawSprite(*_vm->_draw->_spritesArray[Draw::kBackSurface], - *_vm->_draw->_spritesArray[Draw::kAnimSurface], 0, 0, - _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0, 0); + _vm->_draw->_spritesArray[Draw::kAnimSurface]->blit(*_vm->_draw->_spritesArray[Draw::kBackSurface], + 0, 0, _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0); for (_counter = 0; _counter < _objCount; _counter++) _multData->palAnimIndices[_counter] = _counter; @@ -639,9 +638,8 @@ void Mult_v2::drawStatics(bool &stop) { _vm->_scenery->_curStatic = -1; } - _vm->_video->drawSprite(*_vm->_draw->_spritesArray[Draw::kBackSurface], - *_vm->_draw->_spritesArray[Draw::kAnimSurface], 0, 0, - _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0, 0); + _vm->_draw->_spritesArray[Draw::kAnimSurface]->blit(*_vm->_draw->_spritesArray[Draw::kBackSurface], + 0, 0, _vm->_video->_surfWidth, _vm->_video->_surfHeight, 0, 0); } } diff --git a/engines/gob/save/savefile.cpp b/engines/gob/save/savefile.cpp index e1c4c62b12..79e931fe30 100644 --- a/engines/gob/save/savefile.cpp +++ b/engines/gob/save/savefile.cpp @@ -331,14 +331,18 @@ bool SavePartSprite::readPalette(const byte *palette) { return true; } -bool SavePartSprite::readSprite(const SurfaceDesc &sprite) { +bool SavePartSprite::readSprite(const Surface &sprite) { // The sprite's dimensions have to fit if (((uint32)sprite.getWidth()) != _width) return false; if (((uint32)sprite.getHeight()) != _height) return false; - memcpy(_dataSprite, sprite.getVidMem(), _width * _height); + // Only 8bit sprites supported for now + if (sprite.getBPP() != 1) + return false; + + memcpy(_dataSprite, sprite.getData(), _width * _height); return true; } @@ -357,14 +361,18 @@ bool SavePartSprite::writePalette(byte *palette) const { return true; } -bool SavePartSprite::writeSprite(SurfaceDesc &sprite) const { +bool SavePartSprite::writeSprite(Surface &sprite) const { // The sprite's dimensions have to fit if (((uint32)sprite.getWidth()) != _width) return false; if (((uint32)sprite.getHeight()) != _height) return false; - memcpy(sprite.getVidMem(), _dataSprite, _width * _height); + // Only 8bit sprites supported for now + if (sprite.getBPP() != 1) + return false; + + memcpy(sprite.getData(), _dataSprite, _width * _height); return true; } diff --git a/engines/gob/save/savefile.h b/engines/gob/save/savefile.h index 615be8e0f2..da3696dee8 100644 --- a/engines/gob/save/savefile.h +++ b/engines/gob/save/savefile.h @@ -33,7 +33,7 @@ namespace Gob { class GobEngine; -class SurfaceDesc; +class Surface; /** A class wrapping a save part header. * @@ -162,7 +162,7 @@ public: /** Read a palette into the part. */ bool readPalette(const byte *palette); /** Read a sprite into the part. */ - bool readSprite(const SurfaceDesc &sprite); + bool readSprite(const Surface &sprite); /** Read size bytes of raw data into the sprite. */ bool readSpriteRaw(const byte *data, uint32 size); @@ -170,7 +170,7 @@ public: /** Write a palette out of the part. */ bool writePalette(byte *palette) const; /** Write a sprite out of the part. */ - bool writeSprite(SurfaceDesc &sprite) const; + bool writeSprite(Surface &sprite) const; private: uint32 _width; diff --git a/engines/gob/save/savehandler.cpp b/engines/gob/save/savehandler.cpp index 14cd82480d..8b7a661278 100644 --- a/engines/gob/save/savehandler.cpp +++ b/engines/gob/save/savehandler.cpp @@ -245,7 +245,7 @@ bool TempSpriteHandler::load(int16 dataVar, int32 size, int32 offset) { if ((index < 0) || (index >= SPRITES_COUNT)) return false; - SurfaceDescPtr sprite = _vm->_draw->_spritesArray[index]; + SurfacePtr sprite = _vm->_draw->_spritesArray[index]; // Target sprite exists? if (!sprite) @@ -275,7 +275,7 @@ bool TempSpriteHandler::load(int16 dataVar, int32 size, int32 offset) { } bool TempSpriteHandler::save(int16 dataVar, int32 size, int32 offset) { - SurfaceDescPtr sprite; + SurfacePtr sprite; if (isDummy(size)) return true; @@ -297,7 +297,7 @@ bool TempSpriteHandler::save(int16 dataVar, int32 size, int32 offset) { } bool TempSpriteHandler::createSprite(int16 dataVar, int32 size, - int32 offset, SurfaceDescPtr *sprite) { + int32 offset, SurfacePtr *sprite) { delete _sprite; _sprite = 0; @@ -311,7 +311,7 @@ bool TempSpriteHandler::createSprite(int16 dataVar, int32 size, if ((index < 0) || (index >= SPRITES_COUNT)) return false; - SurfaceDescPtr sprt = _vm->_draw->_spritesArray[index]; + SurfacePtr sprt = _vm->_draw->_spritesArray[index]; // Sprite exists? if (!sprt) diff --git a/engines/gob/save/savehandler.h b/engines/gob/save/savehandler.h index 6a7e563a8f..723215cf08 100644 --- a/engines/gob/save/savehandler.h +++ b/engines/gob/save/savehandler.h @@ -27,7 +27,7 @@ #define GOB_SAVE_SAVEHANDLER_H #include "common/savefile.h" -#include "engines/gob/video.h" // for SurfaceDescPtr +#include "engines/gob/video.h" // for SurfacePtr namespace Gob { @@ -139,7 +139,7 @@ public: /** Create a fitting sprite. */ bool createSprite(int16 dataVar, int32 size, - int32 offset, SurfaceDescPtr *sprite = 0); + int32 offset, SurfacePtr *sprite = 0); protected: SavePartSprite *_sprite; diff --git a/engines/gob/scenery.cpp b/engines/gob/scenery.cpp index a667d6615d..0efdf9983c 100644 --- a/engines/gob/scenery.cpp +++ b/engines/gob/scenery.cpp @@ -196,7 +196,7 @@ int16 Scenery::loadStatic(char search) { _spriteResId[sprIndex] = sprResId; _vm->_draw->initSpriteSurf(sprIndex, width, height, 2); - _vm->_video->clearSurf(*_vm->_draw->_spritesArray[sprIndex]); + _vm->_draw->_spritesArray[sprIndex]->clear(); _vm->_draw->_destSurface = sprIndex; _vm->_draw->_spriteLeft = sprResId; _vm->_draw->_transparency = 0; @@ -526,7 +526,7 @@ int16 Scenery::loadAnim(char search) { _spriteResId[sprIndex] = sprResId; _vm->_draw->initSpriteSurf(sprIndex, width, height, 2); - _vm->_video->clearSurf(*_vm->_draw->_spritesArray[sprIndex]); + _vm->_draw->_spritesArray[sprIndex]->clear(); _vm->_draw->_destSurface = sprIndex; _vm->_draw->_spriteLeft = sprResId; _vm->_draw->_transparency = 0; @@ -723,7 +723,7 @@ void Scenery::updateAnim(int16 layer, int16 frame, int16 animation, int16 flags, _vm->_draw->_spriteLeft = _vm->_vidPlayer->getWidth(obj.videoSlot - 1) - (destX + _vm->_draw->_spriteRight); - _vm->_vidPlayer->copyFrame(obj.videoSlot - 1, _vm->_draw->_backSurface->getVidMem(), + _vm->_vidPlayer->copyFrame(obj.videoSlot - 1, _vm->_draw->_backSurface->getData(), _vm->_draw->_spriteLeft, _vm->_draw->_spriteTop, _vm->_draw->_spriteRight, _vm->_draw->_spriteBottom, _vm->_draw->_destSpriteX, _vm->_draw->_destSpriteY, diff --git a/engines/gob/video.cpp b/engines/gob/video.cpp index 6d2636d067..1de25cb594 100644 --- a/engines/gob/video.cpp +++ b/engines/gob/video.cpp @@ -89,81 +89,66 @@ uint16 Font::getCharCount() const { return _endItem - _startItem + 1; } -uint8 Font::getFirstChar() const { - return _startItem; -} - -uint8 Font::getLastChar() const { - return _endItem; -} - -uint8 Font::getCharSize() const { - return _itemSize; -} - bool Font::isMonospaced() const { return _charWidths == 0; } -const byte *Font::getCharData(uint8 c) const { - if (_endItem == 0) { - warning("Font::getCharData(): _endItem == 0"); - return 0; +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; } - if ((c < _startItem) || (c > _endItem)) - return 0; + Pixel dst = surf.get(x, y); - return _data + (c - _startItem) * _itemSize; -} + int nWidth = _itemWidth; + if (nWidth & 7) + nWidth = (nWidth & 0xF8) + 8; + nWidth >>= 3; -SurfaceDesc::SurfaceDesc(int16 vidMode, int16 width, int16 height, - byte *vidMem) : _width(width), _height(height) { + for (int i = 0; i < _itemHeight; i++) { + int width = _itemWidth; - if (vidMem) { - _vidMode = vidMode; - _ownVidMem = false; - _vidMem = vidMem; - } else { - _vidMode = vidMode; - _ownVidMem = true; - _vidMem = new byte[width * height]; - assert(_vidMem); - memset(_vidMem, 0, width * height); - } -} + for (int k = 0; k < nWidth; k++) { -void SurfaceDesc::setVidMem(byte *vidMem) { - assert(vidMem); + data = *src++; + for (int j = 0; j < MIN(8, width); j++) { + if (data & 0x80) + dst.set(color1); + else if (!transp) + dst.set(color2); - if (hasOwnVidMem()) - delete[] _vidMem; + dst++; + data <<= 1; + } - _ownVidMem = false; - _vidMem = vidMem; -} + width -= 8; -void SurfaceDesc::resize(int16 width, int16 height) { - if (hasOwnVidMem()) - delete[] _vidMem; + } - _width = width; - _height = height; - _ownVidMem = true; - _vidMem = new byte[width * height]; - assert(_vidMem); - memset(_vidMem, 0, width * height); + dst += surf.getWidth() - _itemWidth; + } } -void SurfaceDesc::swap(SurfaceDesc &surf) { - SWAP(_width, surf._width); - SWAP(_height, surf._height); - SWAP(_vidMode, surf._vidMode); - SWAP(_ownVidMem, surf._ownVidMem); - SWAP(_vidMem, surf._vidMem); +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; } + Video::Video(GobEngine *vm) : _vm(vm) { _doRangeClamp = false; _videoDriver = 0; @@ -222,8 +207,8 @@ void Video::initPrimary(int16 mode) { } } -SurfaceDescPtr Video::initSurfDesc(int16 vidMode, int16 width, int16 height, int16 flags) { - SurfaceDescPtr descPtr; +SurfacePtr Video::initSurfDesc(int16 vidMode, int16 width, int16 height, int16 flags) { + SurfacePtr descPtr; if (flags & PRIMARY_SURFACE) assert((width == _surfWidth) && (height == _surfHeight)); @@ -236,14 +221,13 @@ SurfaceDescPtr Video::initSurfDesc(int16 vidMode, int16 width, int16 height, int descPtr = _vm->_global->_primarySurfDesc; descPtr->resize(width, height); - descPtr->_vidMode = vidMode; } else { assert(!(flags & DISABLE_SPR_ALLOC)); if (!(flags & SCUMMVM_CURSOR)) width = (width + 7) & 0xFFF8; - descPtr = SurfaceDescPtr(new SurfaceDesc(vidMode, width, height)); + descPtr = SurfacePtr(new Surface(width, height, 1)); } return descPtr; } @@ -280,8 +264,7 @@ void Video::retrace(bool mouse) { screenWidth = MIN<int>(_vm->_width, _splitSurf->getWidth()); screenHeight = _splitSurf->getHeight(); - g_system->copyRectToScreen(_splitSurf->getVidMem() + screenOffset, - _splitSurf->getWidth(), screenX, screenY, screenWidth, screenHeight); + _splitSurf->blitToScreen(0, 0, screenWidth - 1, screenHeight - 1, screenX, screenY); } else if (_splitHeight2 > 0) { @@ -317,191 +300,58 @@ void Video::sparseRetrace(int max) { _lastSparse = timeKey; } -void Video::putPixel(int16 x, int16 y, int16 color, SurfaceDesc &dest) { - if ((x >= dest.getWidth()) || (x < 0) || - (y >= dest.getHeight()) || (y < 0)) - return; +void Video::drawPacked(byte *sprBuf, int16 width, int16 height, + int16 x, int16 y, byte transp, Surface &dest) { - _videoDriver->putPixel(x, y, color, dest); -} - -void Video::fillRect(SurfaceDesc &dest, int16 left, int16 top, int16 right, - int16 bottom, int16 color) { - - if (_doRangeClamp) { - if (left > right) - SWAP(left, right); - if (top > bottom) - SWAP(top, bottom); - - if ((left >= dest.getWidth()) || (right < 0) || - (top >= dest.getHeight()) || (bottom < 0)) - return; - - left = CLIP(left, (int16)0, (int16)(dest.getWidth() - 1)); - top = CLIP(top, (int16)0, (int16)(dest.getHeight() - 1)); - right = CLIP(right, (int16)0, (int16)(dest.getWidth() - 1)); - bottom = CLIP(bottom, (int16)0, (int16)(dest.getHeight() - 1)); - } - - _videoDriver->fillRect(dest, left, top, right, bottom, color); -} - -void Video::drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1, - int16 y1, int16 color) { - - if ((x0 == x1) || (y0 == y1)) - Video::fillRect(dest, x0, y0, x1, y1, color); - else - _videoDriver->drawLine(dest, x0, y0, x1, y1, color); -} - -/* - * The original's version of the Bresenham Algorithm was a bit "unclean" - * and produced strange edges at 45, 135, 225 and 315 degrees, so using the - * version found in the Wikipedia article about the - * "Bresenham's line algorithm" instead - */ -void Video::drawCircle(SurfaceDesc &dest, int16 x0, int16 y0, - int16 radius, int16 color) { - int16 f = 1 - radius; - int16 ddFx = 0; - int16 ddFy = -2 * radius; - int16 x = 0; - int16 y = radius; - int16 tmpPattern = (_vm->_draw->_pattern & 0xFF); - - if (tmpPattern == 0) { - putPixel(x0, y0 + radius, color, dest); - putPixel(x0, y0 - radius, color, dest); - putPixel(x0 + radius, y0, color, dest); - putPixel(x0 - radius, y0, color, dest); - } else - warning ("Video::drawCircle - pattern %d", _vm->_draw->_pattern); - - while (x < y) { - if (f >= 0) { - y--; - ddFy += 2; - f += ddFy; - } - x++; - ddFx += 2; - f += ddFx + 1; - - switch (tmpPattern) { - case -1: - fillRect(dest, x0 - y, y0 + x, x0 + y, y0 + x, color); - fillRect(dest, x0 - x, y0 + y, x0 + x, y0 + y, color); - fillRect(dest, x0 - y, y0 - x, x0 + y, y0 - x, color); - fillRect(dest, x0 - x, y0 - y, x0 + x, y0 - y, color); - break; - case 0: - putPixel(x0 + x, y0 + y, color, dest); - putPixel(x0 - x, y0 + y, color, dest); - putPixel(x0 + x, y0 - y, color, dest); - putPixel(x0 - x, y0 - y, color, dest); - putPixel(x0 + y, y0 + x, color, dest); - putPixel(x0 - y, y0 + x, color, dest); - putPixel(x0 + y, y0 - x, color, dest); - putPixel(x0 - y, y0 - x, color, dest); - break; - default: - fillRect(dest, x0 + y - tmpPattern, y0 + x - tmpPattern, x0 + y, y0 + x, color); - fillRect(dest, x0 + x - tmpPattern, y0 + y - tmpPattern, x0 + x, y0 + y, color); - fillRect(dest, x0 - y, y0 + x - tmpPattern, x0 - y + tmpPattern, y0 + x, color); - fillRect(dest, x0 - x, y0 + y - tmpPattern, x0 - x + tmpPattern, y0 + y, color); - fillRect(dest, x0 + y - tmpPattern, y0 - x, x0 + y, y0 - x + tmpPattern, color); - fillRect(dest, x0 + x - tmpPattern, y0 - y, x0 + x, y0 - y + tmpPattern, color); - fillRect(dest, x0 - y, y0 - x, x0 - y + tmpPattern, y0 - x + tmpPattern, color); - fillRect(dest, x0 - x, y0 - y, x0 - x + tmpPattern, y0 - y + tmpPattern, color); - break; - } - } -} - -void Video::clearSurf(SurfaceDesc &dest) { - Video::fillRect(dest, 0, 0, dest.getWidth() - 1, dest.getHeight() - 1, 0); -} + int destRight = x + width; + int destBottom = y + height; -void Video::drawSprite(SurfaceDesc &source, SurfaceDesc &dest, - int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) { - int16 destRight; - int16 destBottom; + Pixel dst = dest.get(x, y); - if (_doRangeClamp) { - if (left > right) - SWAP(left, right); - if (top > bottom) - SWAP(top, bottom); + int curx = x; + int cury = y; - if ((left >= source.getWidth()) || (right < 0) || - (top >= source.getHeight()) || (bottom < 0)) - return; + while (1) { + uint8 val = *sprBuf++; + unsigned int repeat = val & 7; + val &= 0xF8; - if (left < 0) { - x -= left; - left = 0; + if (!(val & 8)) { + repeat <<= 8; + repeat |= *sprBuf++; } - if (top < 0) { - y -= top; - top = 0; + 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; + } } - right = CLIP(right, (int16)0, (int16)(source.getWidth() - 1)); - bottom = CLIP(bottom, (int16)0, (int16)(source.getHeight() - 1)); - if (right - left >= source.getWidth()) - right = left + source.getWidth() - 1; - if (bottom - top >= source.getHeight()) - bottom = top + source.getHeight() - 1; - - if (x < 0) { - left -= x; - x = 0; - } - if (y < 0) { - top -= y; - y = 0; - } - if ((x >= dest.getWidth()) || (left > right) || - (y >= dest.getHeight()) || (top > bottom)) - return; - destRight = x + right - left; - destBottom = y + bottom - top; - if (destRight >= dest.getWidth()) - right -= destRight - dest.getWidth() + 1; - - if (destBottom >= dest.getHeight()) - bottom -= destBottom - dest.getHeight() + 1; } - - _videoDriver->drawSprite(source, dest, left, top, right, bottom, x, y, transp); -} - -void Video::drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, - int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) { - - _videoDriver->drawSpriteDouble(source, dest, left, top, right, bottom, x, y, transp); -} - -void Video::drawLetter(int16 item, int16 x, int16 y, const Font &font, - int16 color1, int16 color2, int16 transp, SurfaceDesc &dest) { - assert(item != 0x00); - _videoDriver->drawLetter((unsigned char)item, x, y, font, color1, color2, transp, dest); } void Video::drawPackedSprite(byte *sprBuf, int16 width, int16 height, - int16 x, int16 y, int16 transp, SurfaceDesc &dest) { + int16 x, int16 y, int16 transp, Surface &dest) { if (spriteUncompressor(sprBuf, width, height, x, y, transp, dest)) return; - _vm->validateVideoMode(dest._vidMode); - - _videoDriver->drawPackedSprite(sprBuf, width, height, x, y, transp, dest); + drawPacked(sprBuf, width, height, x, y, transp, dest); } -void Video::drawPackedSprite(const char *path, SurfaceDesc &dest, int width) { +void Video::drawPackedSprite(const char *path, Surface &dest, int width) { byte *data; data = _vm->_dataIO->getData(path); @@ -589,32 +439,25 @@ void Video::dirtyRectsAdd(int16 left, int16 top, int16 right, int16 bottom) { } void Video::dirtyRectsApply(int left, int top, int width, int height, int x, int y) { - byte *vidMem = _vm->_global->_primarySurfDesc->getVidMem(); - if (_dirtyAll) { - g_system->copyRectToScreen(vidMem + top * _surfWidth + left, - _surfWidth, x, y, width, height); + _vm->_global->_primarySurfDesc->blitToScreen(left, top, left + width - 1, top + height - 1, x, y); return; } - int right = left + width; - int bottom = top + height; + int right = left + width; + int bottom = top + height; Common::List<Common::Rect>::const_iterator it; for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) { - int l = MAX<int>(left, it->left); - int t = MAX<int>(top, it->top); - int r = MIN<int>(right, it->right); + int l = MAX<int>(left , it->left); + int t = MAX<int>(top , it->top); + int r = MIN<int>(right , it->right); int b = MIN<int>(bottom, it->bottom); - int w = r - l; - int h = b - t; - if ((w <= 0) || (h <= 0)) + if ((r <= l) || (b <= t)) continue; - byte *v = vidMem + t * _surfWidth + l; - - g_system->copyRectToScreen(v, _surfWidth, x + (l - left), y + (t - top), w, h); + _vm->_global->_primarySurfDesc->blitToScreen(l, t, r - 1, b - 1, x + (l - left), y + (t - top)); } } diff --git a/engines/gob/video.h b/engines/gob/video.h index d30a486189..498f6d8650 100644 --- a/engines/gob/video.h +++ b/engines/gob/video.h @@ -31,25 +31,23 @@ #include "common/ptr.h" #include "gob/gob.h" +#include "gob/surface.h" namespace Gob { class Font { public: + Font(const byte *data); + ~Font(); + uint8 getCharWidth (uint8 c) const; uint8 getCharWidth () const; uint8 getCharHeight() const; - uint16 getCharCount () const; - uint8 getFirstChar () const; - uint8 getLastChar () const; - uint8 getCharSize () const; bool isMonospaced() const; - const byte *getCharData(uint8 c) const; - - Font(const byte *data); - ~Font(); + void drawLetter(Surface &surf, uint8 c, uint16 x, uint16 y, + uint32 color1, uint32 color2, bool transp) const; private: const byte *_dataPtr; @@ -62,46 +60,19 @@ private: uint8 _endItem; int8 _itemSize; int8 _bitWidth; -}; - -// Some Surfaces are simultaneous in Draw::spritesArray and discrete -// variables, so if in doubt you should use a SurfaceDescPtr shared -// pointer object to refer to any SurfaceDesc. -class SurfaceDesc { -public: - int16 _vidMode; - int16 getWidth() const { return _width; } - int16 getHeight() const { return _height; } - byte *getVidMem() { return _vidMem; } - const byte *getVidMem() const { return _vidMem; } - bool hasOwnVidMem() const { return _ownVidMem; } - - void setVidMem(byte *vidMem); - void resize(int16 width, int16 height); - void swap(SurfaceDesc &surf); - - SurfaceDesc(int16 vidMode, int16 width, int16 height, byte *vidMem = 0); - ~SurfaceDesc() { if (_ownVidMem) delete[] _vidMem; } - -private: - int16 _width; - int16 _height; - byte *_vidMem; - bool _ownVidMem; + uint16 getCharCount() const; + const byte *getCharData(uint8 c) const; }; -typedef Common::SharedPtr<SurfaceDesc> SurfaceDescPtr; - - class Video { public: -#define GDR_VERSION 4 +#define GDR_VERSION 4 -#define PRIMARY_SURFACE 0x80 -#define RETURN_PRIMARY 0x01 -#define DISABLE_SPR_ALLOC 0x20 -#define SCUMMVM_CURSOR 0x100 +#define PRIMARY_SURFACE 0x80 +#define RETURN_PRIMARY 0x01 +#define DISABLE_SPR_ALLOC 0x20 +#define SCUMMVM_CURSOR 0x100 #include "common/pack-start.h" // START STRUCT PACKING @@ -128,7 +99,7 @@ public: int16 _scrollOffsetX; int16 _scrollOffsetY; - SurfaceDescPtr _splitSurf; + SurfacePtr _splitSurf; int16 _splitHeight1; int16 _splitHeight2; int16 _splitStart; @@ -138,7 +109,7 @@ public: void freeDriver(); void initPrimary(int16 mode); - SurfaceDescPtr initSurfDesc(int16 vidMode, int16 width, + SurfacePtr initSurfDesc(int16 vidMode, int16 width, int16 height, int16 flags); void setSize(bool defaultTo1XScaler); @@ -148,25 +119,9 @@ public: void waitRetrace(bool mouse = true); void sparseRetrace(int max); - void putPixel(int16 x, int16 y, int16 color, SurfaceDesc &dest); - virtual void fillRect(SurfaceDesc &dest, int16 left, int16 top, - int16 right, int16 bottom, int16 color); - void drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1, int16 y1, - int16 color); - void drawCircle(SurfaceDesc &dest, int16 x0, int16 y0, - int16 radius, int16 color); - void clearSurf(SurfaceDesc &dest); - void drawSprite(SurfaceDesc &source, SurfaceDesc &dest, - int16 left, int16 top, int16 right, int16 bottom, - int16 x, int16 y, int16 transp); - void drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, - int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp); - void drawLetter(int16 item, int16 x, int16 y, const Font &font, - int16 color1, int16 color2, int16 transp, SurfaceDesc &dest); void drawPackedSprite(byte *sprBuf, int16 width, int16 height, - int16 x, int16 y, int16 transp, SurfaceDesc &dest); - void drawPackedSprite(const char *path, SurfaceDesc &dest, - int width = 320); + int16 x, int16 y, int16 transp, Surface &dest); + void drawPackedSprite(const char *path, Surface &dest, int width = 320); void setPalColor(byte *pal, byte red, byte green, byte blue) { pal[0] = red << 2; @@ -190,7 +145,7 @@ public: virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, int16 x, int16 y, int16 transp, - SurfaceDesc &destDesc) = 0; + Surface &destDesc) = 0; Video(class GobEngine *vm); virtual ~Video(); @@ -207,12 +162,14 @@ protected: GobEngine *_vm; char initDriver(int16 vidMode); + + void drawPacked(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, Surface &dest); }; class Video_v1 : public Video { public: virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, - int16 x, int16 y, int16 transp, SurfaceDesc &destDesc); + int16 x, int16 y, int16 transp, Surface &destDesc); Video_v1(GobEngine *vm); virtual ~Video_v1() {} @@ -221,7 +178,7 @@ public: class Video_v2 : public Video_v1 { public: virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, - int16 x, int16 y, int16 transp, SurfaceDesc &destDesc); + int16 x, int16 y, int16 transp, Surface &destDesc); Video_v2(GobEngine *vm); virtual ~Video_v2() {} @@ -230,10 +187,7 @@ public: class Video_v6 : public Video_v2 { public: virtual char spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, - int16 x, int16 y, int16 transp, SurfaceDesc &destDesc); - - virtual void fillRect(SurfaceDesc &dest, int16 left, int16 top, - int16 right, int16 bottom, int16 color); + int16 x, int16 y, int16 transp, Surface &destDesc); Video_v6(GobEngine *vm); virtual ~Video_v6() {} @@ -243,13 +197,13 @@ private: void buildPalLUT(); - void shadeRect(SurfaceDesc &dest, + void shadeRect(Surface &dest, int16 left, int16 top, int16 right, int16 bottom, byte color, byte strength); - void drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc &surfDesc); - void drawYUVData(const byte *srcData, SurfaceDesc &destDesc, + void drawPacked(const byte *sprBuf, int16 x, int16 y, Surface &surfDesc); + void drawYUVData(const byte *srcData, Surface &destDesc, int16 width, int16 height, int16 x, int16 y); - void drawYUV(SurfaceDesc &destDesc, int16 x, int16 y, + void drawYUV(Surface &destDesc, int16 x, int16 y, int16 dataWidth, int16 dataHeight, int16 width, int16 height, const byte *dataY, const byte *dataU, const byte *dataV); }; @@ -258,13 +212,13 @@ class VideoDriver { public: VideoDriver() {} virtual ~VideoDriver() {} - virtual void drawSprite(SurfaceDesc &source, SurfaceDesc &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0; - virtual void drawSpriteDouble(SurfaceDesc &source, SurfaceDesc &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0; - virtual void fillRect(SurfaceDesc &dest, int16 left, int16 top, int16 right, int16 bottom, byte color) = 0; - virtual void putPixel(int16 x, int16 y, byte color, SurfaceDesc &dest) = 0; - virtual void drawLetter(unsigned char item, int16 x, int16 y, const Font &font, byte color1, byte color2, byte transp, SurfaceDesc &dest) = 0; - virtual void drawLine(SurfaceDesc &dest, int16 x0, int16 y0, int16 x1, int16 y1, byte color) = 0; - virtual void drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, SurfaceDesc &dest) = 0; + virtual void drawSprite(Surface &source, Surface &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0; + virtual void drawSpriteDouble(Surface &source, Surface &dest, int16 left, int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp) = 0; + virtual void fillRect(Surface &dest, int16 left, int16 top, int16 right, int16 bottom, byte color) = 0; + virtual void putPixel(int16 x, int16 y, byte color, Surface &dest) = 0; + virtual void drawLetter(unsigned char item, int16 x, int16 y, const Font &font, byte color1, byte color2, byte transp, Surface &dest) = 0; + virtual void drawLine(Surface &dest, int16 x0, int16 y0, int16 x1, int16 y1, byte color) = 0; + virtual void drawPackedSprite(byte *sprBuf, int16 width, int16 height, int16 x, int16 y, byte transp, Surface &dest) = 0; }; } // End of namespace Gob diff --git a/engines/gob/video_v1.cpp b/engines/gob/video_v1.cpp index 699ac5f934..5c2f17d7dd 100644 --- a/engines/gob/video_v1.cpp +++ b/engines/gob/video_v1.cpp @@ -34,9 +34,9 @@ Video_v1::Video_v1(GobEngine *vm) : Video(vm) { } char Video_v1::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, - int16 x, int16 y, int16 transp, SurfaceDesc &destDesc) { + int16 x, int16 y, int16 transp, Surface &destDesc) { byte *memBuffer; - byte *srcPtr, *destPtr, *linePtr; + byte *srcPtr; byte temp; uint16 sourceLeft; uint16 cmdVar; @@ -46,7 +46,7 @@ char Video_v1::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, int16 bufPos; int16 strLen; - _vm->validateVideoMode(destDesc._vidMode); + //_vm->validateVideoMode(destDesc._vidMode); if (sprBuf[0] != 1) return 0; @@ -55,9 +55,8 @@ char Video_v1::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, return 0; if (sprBuf[2] == 2) { - SurfaceDesc sourceDesc(0x13, srcWidth, srcHeight, sprBuf + 3); - Video::drawSprite(sourceDesc, destDesc, 0, 0, srcWidth - 1, - srcHeight - 1, x, y, transp); + Surface sourceDesc(srcWidth, srcHeight, 1, sprBuf + 3); + destDesc.blit(sourceDesc, 0, 0, srcWidth - 1, srcHeight - 1, x, y, (transp == 0) ? -1 : 0); return 1; } else { memBuffer = new byte[4114]; @@ -66,12 +65,12 @@ char Video_v1::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, srcPtr = sprBuf + 3; sourceLeft = READ_LE_UINT16(srcPtr); - destPtr = destDesc.getVidMem() + destDesc.getWidth() * y + x; + Pixel destPtr = destDesc.get(x, y); curWidth = 0; curHeight = 0; - linePtr = destPtr; + Pixel linePtr = destPtr; srcPtr += 4; for (offset = 0; offset < 4078; offset++) @@ -88,7 +87,7 @@ char Video_v1::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, if ((cmdVar & 1) != 0) { temp = *srcPtr++; if ((temp != 0) || (transp == 0)) - *destPtr = temp; + destPtr.set(temp); destPtr++; curWidth++; if (curWidth >= srcWidth) { @@ -116,7 +115,7 @@ char Video_v1::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, for (counter2 = 0; counter2 < strLen; counter2++) { temp = memBuffer[(offset + counter2) % 4096]; if ((temp != 0) || (transp == 0)) - *destPtr = temp; + destPtr.set(temp); destPtr++; curWidth++; diff --git a/engines/gob/video_v2.cpp b/engines/gob/video_v2.cpp index 98cf4a5d4f..c908ccf7b1 100644 --- a/engines/gob/video_v2.cpp +++ b/engines/gob/video_v2.cpp @@ -34,9 +34,9 @@ Video_v2::Video_v2(GobEngine *vm) : Video_v1(vm) { } char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, - int16 x, int16 y, int16 transp, SurfaceDesc &destDesc) { + int16 x, int16 y, int16 transp, Surface &destDesc) { byte *memBuffer; - byte *srcPtr, *destPtr, *linePtr; + byte *srcPtr; byte temp; uint32 sourceLeft; uint16 cmdVar; @@ -47,7 +47,7 @@ char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, int16 strLen; int16 lenCmd; - _vm->validateVideoMode(destDesc._vidMode); + //_vm->validateVideoMode(destDesc._vidMode); if (sprBuf[0] != 1) return 0; @@ -56,9 +56,8 @@ char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, return 0; if (sprBuf[2] == 2) { - SurfaceDesc sourceDesc(0x13, srcWidth, srcHeight, sprBuf + 3); - Video::drawSprite(sourceDesc, destDesc, 0, 0, srcWidth - 1, - srcHeight - 1, x, y, transp); + Surface sourceDesc(srcWidth, srcHeight, 1, sprBuf + 3); + destDesc.blit(sourceDesc, 0, 0, srcWidth - 1, srcHeight - 1, x, y, (transp == 0) ? -1 : 0); return 1; } else if (sprBuf[2] == 1) { memBuffer = new byte[4370]; @@ -70,12 +69,12 @@ char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, sourceLeft = READ_LE_UINT32(srcPtr); - destPtr = destDesc.getVidMem() + destDesc.getWidth() * y + x; + Pixel destPtr = destDesc.get(x, y); curWidth = 0; curHeight = 0; - linePtr = destPtr; + Pixel linePtr = destPtr; srcPtr += 4; if ((READ_LE_UINT16(srcPtr) == 0x1234) && (READ_LE_UINT16(srcPtr + 2) == 0x5678)) { @@ -99,7 +98,7 @@ char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, temp = *srcPtr++; if ((temp != 0) || (transp == 0)) - *destPtr = temp; + destPtr.set(temp); destPtr++; curWidth++; @@ -133,7 +132,7 @@ char Video_v2::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, temp = memBuffer[(offset + counter2) % 4096]; if ((temp != 0) || (transp == 0)) - *destPtr = temp; + destPtr.set(temp); destPtr++; curWidth++; diff --git a/engines/gob/video_v6.cpp b/engines/gob/video_v6.cpp index 3f1055c48a..355cf38468 100644 --- a/engines/gob/video_v6.cpp +++ b/engines/gob/video_v6.cpp @@ -38,8 +38,7 @@ Video_v6::Video_v6(GobEngine *vm) : Video_v2(vm) { } char Video_v6::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, - int16 x, int16 y, int16 transp, SurfaceDesc &destDesc) { - _vm->validateVideoMode(destDesc._vidMode); + int16 x, int16 y, int16 transp, Surface &destDesc) { if ((sprBuf[0] == 1) && (sprBuf[1] == 3)) { drawPacked(sprBuf, x, y, destDesc); @@ -55,9 +54,7 @@ char Video_v6::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, if (Video_v2::spriteUncompressor(sprBuf, srcWidth, srcHeight, x, y, transp, destDesc)) return 1; - _vm->validateVideoMode(destDesc._vidMode); - - _videoDriver->drawPackedSprite(sprBuf, srcWidth, srcHeight, x, y, transp, destDesc); + Video::drawPacked(sprBuf, srcWidth, srcHeight, x, y, transp, destDesc); return 1; } @@ -66,7 +63,8 @@ char Video_v6::spriteUncompressor(byte *sprBuf, int16 srcWidth, int16 srcHeight, return 1; } -void Video_v6::fillRect(SurfaceDesc &dest, +/* +void Video_v6::fillRect(Surface &dest, int16 left, int16 top, int16 right, int16 bottom, int16 color) { if (!(color & 0xFF00)) { @@ -98,8 +96,9 @@ void Video_v6::fillRect(SurfaceDesc &dest, byte strength = 16 - (((uint16) color) >> 12); shadeRect(dest, left, top, right, bottom, color, strength); } +*/ -void Video_v6::shadeRect(SurfaceDesc &dest, +void Video_v6::shadeRect(Surface &dest, int16 left, int16 top, int16 right, int16 bottom, byte color, byte strength) { warning("TODO: Video_v6::shadeRect()"); @@ -144,7 +143,7 @@ void Video_v6::shadeRect(SurfaceDesc &dest, */ } -void Video_v6::drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc &surfDesc) { +void Video_v6::drawPacked(const byte *sprBuf, int16 x, int16 y, Surface &surfDesc) { const byte *data = sprBuf + 2; int16 width = READ_LE_UINT16(data); @@ -170,7 +169,7 @@ void Video_v6::drawPacked(const byte *sprBuf, int16 x, int16 y, SurfaceDesc &sur delete[] uncBuf; } -void Video_v6::drawYUVData(const byte *srcData, SurfaceDesc &destDesc, +void Video_v6::drawYUVData(const byte *srcData, Surface &destDesc, int16 width, int16 height, int16 x, int16 y) { int16 dataWidth = width; @@ -189,7 +188,7 @@ void Video_v6::drawYUVData(const byte *srcData, SurfaceDesc &destDesc, } -void Video_v6::drawYUV(SurfaceDesc &destDesc, int16 x, int16 y, +void Video_v6::drawYUV(Surface &destDesc, int16 x, int16 y, int16 dataWidth, int16 dataHeight, int16 width, int16 height, const byte *dataY, const byte *dataU, const byte *dataV) { diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp index 9e49bfc092..f349413b93 100644 --- a/engines/gob/videoplayer.cpp +++ b/engines/gob/videoplayer.cpp @@ -155,8 +155,8 @@ int VideoPlayer::openVideo(bool primary, const Common::String &file, Properties video->decoder->setXY(0, 0); } else { video->surface = _vm->_draw->_spritesArray[properties.sprite]; - video->decoder->setSurfaceMemory(video->surface->getVidMem(), - video->surface->getWidth(), video->surface->getHeight(), 1); + video->decoder->setSurfaceMemory(video->surface->getData(), + video->surface->getWidth(), video->surface->getHeight(), video->surface->getBPP()); if (!ownSurf || (ownSurf && screenSize)) { if ((properties.x >= 0) || (properties.y >= 0)) diff --git a/engines/gob/videoplayer.h b/engines/gob/videoplayer.h index d91d0a3845..c154254455 100644 --- a/engines/gob/videoplayer.h +++ b/engines/gob/videoplayer.h @@ -137,7 +137,7 @@ private: Graphics::CoktelDecoder *decoder; Common::String fileName; - SurfaceDescPtr surface; + SurfacePtr surface; Video(); |