From a741f3c0100127d009272689f6507b57ed2ca419 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Mon, 25 Jun 2007 14:40:40 +0000 Subject: [PATCH] Fix priority screen showing when using AGI256 or AGI256-2. svn-id: r27707 --- engines/agi/graphics.cpp | 9 +++++++-- engines/agi/picture.cpp | 2 +- engines/agi/sprite.cpp | 13 +++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 2d64a4352e4..193485ebe3b 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -804,9 +804,14 @@ int GfxMgr::deinitMachine() { * @param x x coordinate of the row start (AGI coord.) * @param y y coordinate of the row start (AGI coord.) * @param n number of pixels in the row - * @param p pointer to the row start in the AGI screen + * @param p pointer to the row start in the AGI screen (Always use sbuf16c as base, not sbuf256c) + * FIXME: CGA rendering doesn't work correctly with AGI256 or AGI256-2. */ void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) { + // Choose the correct screen to read from. If AGI256 or AGI256-2 is used and we're not trying to show the priority information, + // then choose the 256 color screen, otherwise choose the 16 color screen (Which also has the priority information). + p += _vm->getFeatures() & (GF_AGI256 | GF_AGI256_2) && !_vm->_debug.priority ? FROM_SBUF16_TO_SBUF256_OFFSET : 0; + if (_vm->_renderMode == Common::kRenderCGA) { for (x *= 2; n--; p++, x += 2) { register uint16 q = (cgaMap[(*p & 0xf0) >> 4] << 4) | cgaMap[*p & 0x0f]; @@ -815,7 +820,7 @@ void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) { *(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = q & 0x0f0f; } } else { - const uint16 mask = _vm->getFeatures() & (GF_AGI256 | GF_AGI256_2) ? 0xffff : 0x0f0f; + const uint16 mask = _vm->getFeatures() & (GF_AGI256 | GF_AGI256_2) && !_vm->_debug.priority ? 0xffff : 0x0f0f; for (x *= 2; n--; p++, x += 2) { register uint16 q = ((uint16) * p << 8) | *p; if (_vm->_debug.priority) diff --git a/engines/agi/picture.cpp b/engines/agi/picture.cpp index cd8ef83de06..e3fd2277d01 100644 --- a/engines/agi/picture.cpp +++ b/engines/agi/picture.cpp @@ -686,7 +686,7 @@ void PictureMgr::showPic() { i = 0; offset = _vm->_game.lineMinPrint * CHAR_LINES; for (y = 0; y < _HEIGHT; y++) { - _gfx->putPixelsA(0, y + offset, _WIDTH, &_vm->_game.sbuf[i]); + _gfx->putPixelsA(0, y + offset, _WIDTH, &_vm->_game.sbuf16c[i]); i += _WIDTH; } diff --git a/engines/agi/sprite.cpp b/engines/agi/sprite.cpp index 3d699680753..006e3dddeed 100644 --- a/engines/agi/sprite.cpp +++ b/engines/agi/sprite.cpp @@ -215,7 +215,8 @@ void SpritesMgr::objsRestoreArea(Sprite *s) { int y, offset; int16 xPos = s->xPos, yPos = s->yPos; int16 xSize = s->xSize, ySize = s->ySize; - uint8 *p0, *q; + uint8 *q; + uint32 pos0; if (xPos + xSize > _WIDTH) xSize = _WIDTH - xPos; @@ -236,14 +237,14 @@ void SpritesMgr::objsRestoreArea(Sprite *s) { if (xSize <= 0 || ySize <= 0) return; - p0 = &_vm->_game.sbuf[xPos + yPos * _WIDTH]; + pos0 = xPos + yPos * _WIDTH; q = s->buffer; offset = _vm->_game.lineMinPrint * CHAR_LINES; for (y = 0; y < ySize; y++) { - memcpy(p0, q, xSize); - _gfx->putPixelsA(xPos, yPos + y + offset, xSize, p0); + memcpy(&_vm->_game.sbuf[pos0], q, xSize); + _gfx->putPixelsA(xPos, yPos + y + offset, xSize, &_vm->_game.sbuf16c[pos0]); q += xSize; - p0 += _WIDTH; + pos0 += _WIDTH; } } @@ -728,7 +729,7 @@ void SpritesMgr::commitBlock(int x1, int y1, int x2, int y2) { debugC(7, kDebugLevelSprites, "%d, %d, %d, %d", x1, y1, x2, y2); w = x2 - x1 + 1; - q = &_vm->_game.sbuf[x1 + _WIDTH * y1]; + q = &_vm->_game.sbuf16c[x1 + _WIDTH * y1]; offset = _vm->_game.lineMinPrint * CHAR_LINES; for (i = y1; i <= y2; i++) { _gfx->putPixelsA(x1, i + offset, w, q);