diff options
-rw-r--r-- | engines/agi/picture.cpp | 29 | ||||
-rw-r--r-- | engines/agi/picture.h | 7 | ||||
-rw-r--r-- | engines/agi/preagi_mickey.cpp | 4 |
3 files changed, 23 insertions, 17 deletions
diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp index 5737a2ffdf..9945b4f9c6 100644 --- a/engines/agi/picture.cpp +++ b/engines/agi/picture.cpp @@ -84,10 +84,10 @@ static uint8 splatterStart[128] = { /* starting bit position */ void PictureMgr::putVirtPixel(int x, int y) { uint8 *p; - if (x < 0 || y < 0 || x >= _WIDTH || y >= _HEIGHT) + if (x < 0 || y < 0 || x >= width || y >= _HEIGHT) return; - p = &_vm->_game.sbuf16c[y * _WIDTH + x]; + p = &_vm->_game.sbuf16c[y * width + x]; if (priOn) *p = (priColour << 4) | (*p & 0x0f); @@ -131,8 +131,8 @@ void PictureMgr::drawLine(int x1, int y1, int x2, int y2) { /* CM: Do clipping */ #define clip(x, y) if((x)>=(y)) (x)=(y) - clip(x1, _WIDTH - 1); - clip(x2, _WIDTH - 1); + clip(x1, width - 1); + clip(x2, width - 1); clip(y1, _HEIGHT - 1); clip(y2, _HEIGHT - 1); @@ -276,13 +276,13 @@ void PictureMgr::absoluteDrawLine() { INLINE int PictureMgr::isOkFillHere(int x, int y) { uint8 p; - if (x < 0 || x >= _WIDTH || y < 0 || y >= _HEIGHT) + if (x < 0 || x >= width || y < 0 || y >= _HEIGHT) return false; if (!scrOn && !priOn) return false; - p = _vm->_game.sbuf16c[y * _WIDTH + x]; + p = _vm->_game.sbuf16c[y * width + x]; if (!priOn && scrOn && scrColour != 15) return (p & 0x0f) == 15; @@ -714,7 +714,7 @@ uint8 *PictureMgr::convertV3Pic(uint8 *src, uint32 len) { * @param clear clear AGI screen before drawing * @param agi256 load an AGI256 picture resource */ -int PictureMgr::decodePicture(int n, int clear, bool agi256) { +int PictureMgr::decodePicture(int n, int clear, bool agi256, int pic_width) { debugC(8, kDebugLevelResources, "(%d)", n); patCode = 0; @@ -727,20 +727,22 @@ int PictureMgr::decodePicture(int n, int clear, bool agi256) { flen = _vm->_game.dirPic[n].len; foffs = 0; + width = pic_width; + if (clear && !agi256) // 256 color pictures should always fill the whole screen, so no clearing for them. - memset(_vm->_game.sbuf16c, 0x4f, _WIDTH * _HEIGHT); // Clear 16 color AGI screen (Priority 4, color white). + memset(_vm->_game.sbuf16c, 0x4f, width * _HEIGHT); // Clear 16 color AGI screen (Priority 4, color white). if (!agi256) { drawPicture(); // Draw 16 color picture. } else { - const uint32 maxFlen = _WIDTH * _HEIGHT; + const uint32 maxFlen = width * _HEIGHT; memcpy(_vm->_game.sbuf256c, data, MIN(flen, maxFlen)); // Draw 256 color picture. if (flen < maxFlen) { warning("Undersized AGI256 picture resource %d, using it anyway. Filling rest with white.", n); memset(_vm->_game.sbuf256c + flen, 0x0f, maxFlen - flen); // Fill missing area with white. } else if (flen > maxFlen) - warning("Oversized AGI256 picture resource %d, decoding only %ux%u part of it", n, _WIDTH, _HEIGHT); + warning("Oversized AGI256 picture resource %d, decoding only %ux%u part of it", n, width, _HEIGHT); } if (clear) @@ -770,17 +772,18 @@ int PictureMgr::unloadPicture(int n) { * Show AGI picture. * This function copies a ``hidden'' AGI picture to the output device. */ -void PictureMgr::showPic() { +void PictureMgr::showPic(int x, int pic_width) { int i, y; int offset; + width = pic_width; debugC(8, kDebugLevelMain, "Show picture!"); i = 0; offset = _vm->_game.lineMinPrint * CHAR_LINES; for (y = 0; y < _HEIGHT; y++) { - _gfx->putPixelsA(0, y + offset, _WIDTH, &_vm->_game.sbuf16c[i]); - i += _WIDTH; + _gfx->putPixelsA(x, y + offset, width, &_vm->_game.sbuf16c[i]); + i += width; } _gfx->flushScreen(); diff --git a/engines/agi/picture.h b/engines/agi/picture.h index 5ef97c7053..2691be91de 100644 --- a/engines/agi/picture.h +++ b/engines/agi/picture.h @@ -30,6 +30,8 @@ namespace Agi { +#define _DEFAULT_WIDTH 160 + /** * AGI picture resource. */ @@ -72,6 +74,7 @@ private: // TODO: this is hardcoded for V2 pictures for now static const int pictureType = AGIPIC_V2; + int width; public: PictureMgr(AgiBase *agi, GfxMgr *gfx) { @@ -79,9 +82,9 @@ public: _gfx = gfx; } - int decodePicture(int n, int clear, bool agi256 = false); + int decodePicture(int n, int clear, bool agi256 = false, int pic_width = _DEFAULT_WIDTH); int unloadPicture(int); - void showPic(); + void showPic(int x = 0, int pic_width = _DEFAULT_WIDTH); uint8 *convertV3Pic(uint8 *src, uint32 len); }; diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp index ef9d5d87f2..9aca5b33d2 100644 --- a/engines/agi/preagi_mickey.cpp +++ b/engines/agi/preagi_mickey.cpp @@ -620,8 +620,8 @@ void Mickey::drawObj(ENUM_MSA_OBJECT iObj, int x0, int y0) { void Mickey::drawPic(int iPic) { _vm->preAgiLoadResource(rPICTURE, iPic); - _vm->_picture->decodePicture(iPic, true); - _vm->_picture->showPic(); + _vm->_picture->decodePicture(iPic, true, false, _WIDTH - 20); + _vm->_picture->showPic(10, _WIDTH - 20); _vm->_gfx->doUpdate(); _vm->_system->updateScreen(); // TODO: this should go in the game's main loop /* |