diff options
Diffstat (limited to 'engines/toltecs/screen.cpp')
-rw-r--r-- | engines/toltecs/screen.cpp | 340 |
1 files changed, 0 insertions, 340 deletions
diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp index 4f7efaa423..fc981db511 100644 --- a/engines/toltecs/screen.cpp +++ b/engines/toltecs/screen.cpp @@ -266,346 +266,6 @@ void Screen::clearSprites() { } -void Screen::addDrawRequest(const DrawRequest &drawRequest) { - - int16 scaleValueX, scaleValueY; - int16 xoffs, yoffs; - byte *spriteData; - int16 frameNum; - - SpriteDrawItem sprite; - memset(&sprite, 0, sizeof(SpriteDrawItem)); - - if (drawRequest.flags == 0xFFFF) - return; - - sprite.flags = 0; - sprite.baseColor = drawRequest.baseColor; - sprite.x = drawRequest.x; - sprite.y = drawRequest.y; - sprite.ybottom = drawRequest.y; - sprite.resIndex = drawRequest.resIndex; - - spriteData = _vm->_res->load(drawRequest.resIndex); - - if (drawRequest.flags & 0x1000) { - sprite.flags |= 4; - } - - if (drawRequest.flags & 0x2000) { - sprite.flags |= 0x10; - } - - if (drawRequest.flags & 0x4000) { - sprite.flags |= 0x40; - } - - frameNum = drawRequest.flags & 0x0FFF; - - // First initialize the sprite item with the values from the sprite resource - - SpriteFrameEntry spriteFrameEntry(spriteData + frameNum * 12); - - if (spriteFrameEntry.w == 0 || spriteFrameEntry.h == 0) - return; - - sprite.offset = spriteFrameEntry.offset; - - sprite.width = spriteFrameEntry.w; - sprite.height = spriteFrameEntry.h; - - sprite.origWidth = spriteFrameEntry.w; - sprite.origHeight = spriteFrameEntry.h; - - if (drawRequest.flags & 0x1000) { - xoffs = spriteFrameEntry.w - spriteFrameEntry.x; - } else { - xoffs = spriteFrameEntry.x; - } - - yoffs = spriteFrameEntry.y; - - // If the sprite should be scaled we need to initialize some values now - - if (drawRequest.scaling != 0) { - - byte scaleValue = ABS(drawRequest.scaling); - - scaleValueX = scaleValue * sprite.origWidth; - sprite.xdelta = (10000 * sprite.origWidth) / scaleValueX; - scaleValueX /= 100; - - scaleValueY = scaleValue * sprite.origHeight; - sprite.ydelta = (10000 * sprite.origHeight) / scaleValueY; - scaleValueY /= 100; - - if (drawRequest.scaling > 0) { - sprite.flags |= 2; - sprite.width = sprite.origWidth + scaleValueX; - sprite.height = sprite.origHeight + scaleValueY; - xoffs += (xoffs * scaleValue) / 100; - yoffs += (yoffs * scaleValue) / 100; - } else { - sprite.flags |= 1; - sprite.width = sprite.origWidth - scaleValueX; - sprite.height = sprite.origHeight - 1 - scaleValueY; - if (sprite.width <= 0 || sprite.height <= 0) - return; - xoffs -= (xoffs * scaleValue) / 100; - yoffs -= (yoffs * scaleValue) / 100; - } - - } - - sprite.x -= xoffs; - sprite.y -= yoffs; - - sprite.yerror = sprite.ydelta; - - // Now we check if the sprite needs to be clipped - - // Clip Y - if (sprite.y - _vm->_cameraY < 0) { - - int16 clipHeight = ABS(sprite.y - _vm->_cameraY); - int16 chopHeight, skipHeight, lineWidth; - byte *spriteFrameData; - - sprite.height -= clipHeight; - if (sprite.height <= 0) - return; - - sprite.y = _vm->_cameraY; - - // If the sprite is scaled - if (sprite.flags & 3) { - chopHeight = sprite.ydelta; - skipHeight = clipHeight; - if ((sprite.flags & 2) == 0) { - do { - chopHeight -= 100; - if (chopHeight <= 0) { - skipHeight++; - chopHeight += sprite.ydelta; - } else { - clipHeight--; - } - } while (clipHeight > 0); - } else { - do { - chopHeight -= 100; - if (chopHeight < 0) { - skipHeight--; - chopHeight += sprite.ydelta + 100; - } - clipHeight--; - } while (clipHeight > 0); - } - sprite.yerror = chopHeight; - } - - spriteFrameData = spriteData + sprite.offset; - - // Now the sprite's offset is adjusted to point to the starting line - if ((sprite.flags & 0x10) == 0) { - while (clipHeight--) { - lineWidth = 0; - while (lineWidth </*CHECKME was != */ sprite.origWidth) { - sprite.offset++; - lineWidth += (*spriteFrameData++) & 0x0F; - } - } - } else { - lineWidth = 0; - while (clipHeight--) { - while (lineWidth < sprite.origWidth) { - sprite.offset += 2; - spriteFrameData++; - lineWidth += *spriteFrameData++; - } - } - } - - } - - if (sprite.y + sprite.height - _vm->_cameraY - _vm->_cameraHeight > 0) - sprite.height -= sprite.y + sprite.height - _vm->_cameraY - _vm->_cameraHeight; - if (sprite.height <= 0) - return; - - sprite.skipX = 0; - - if (drawRequest.flags & 0x1000) { - // Left border - if (sprite.x - _vm->_cameraX < 0) { - sprite.width -= ABS(sprite.x - _vm->_cameraX); - sprite.x = _vm->_cameraX; - } - // Right border - if (sprite.x + sprite.width - _vm->_cameraX - 640 > 0) { - sprite.flags |= 8; - sprite.skipX = sprite.x + sprite.width - _vm->_cameraX - 640; - sprite.width -= sprite.skipX; - } - } else { - // Left border - if (sprite.x - _vm->_cameraX < 0) { - sprite.flags |= 8; - sprite.skipX = ABS(sprite.x - _vm->_cameraX); - sprite.width -= sprite.skipX; - sprite.x = _vm->_cameraX; - } - // Right border - if (sprite.x + sprite.width - _vm->_cameraX - 640 > 0) { - sprite.flags |= 8; - sprite.width -= sprite.x + sprite.width - _vm->_cameraX - 640; - } - } - - if (sprite.width <= 0) - return; - - // Add sprite sorted by priority - Common::List<SpriteDrawItem>::iterator iter = _spriteDrawList.begin(); - while (iter != _spriteDrawList.end() && (*iter).ybottom <= sprite.ybottom) { - iter++; - } - _spriteDrawList.insert(iter, sprite); - -} - -void Screen::drawSprite(SpriteDrawItem *sprite) { - - debug(0, "Screen::drawSprite() x = %d; y = %d; flags = %04X; resIndex = %d; offset = %08X; drawX = %d; drawY = %d", - sprite->x, sprite->y, sprite->flags, sprite->resIndex, sprite->offset, - sprite->x - _vm->_cameraX, sprite->y - _vm->_cameraY); - debug(0, "Screen::drawSprite() width = %d; height = %d; origWidth = %d; origHeight = %d", - sprite->width, sprite->height, sprite->origWidth, sprite->origHeight); - - byte *source = _vm->_res->load(sprite->resIndex) + sprite->offset; - byte *dest = _frontScreen + (sprite->x - _vm->_cameraX) + (sprite->y - _vm->_cameraY) * 640; - - SpriteReader spriteReader(source, sprite); - - if (sprite->flags & 0x40) { - // Shadow sprites - if (sprite->flags & 1) { - SpriteFilterScaleDown spriteScaler(sprite, &spriteReader); - drawSpriteCore(dest, spriteScaler, sprite); - } else if (sprite->flags & 2) { - SpriteFilterScaleUp spriteScaler(sprite, &spriteReader); - drawSpriteCore(dest, spriteScaler, sprite); - } else { - drawSpriteCore(dest, spriteReader, sprite); - } - } else if (sprite->flags & 0x10) { - // 256 color sprite - drawSpriteCore(dest, spriteReader, sprite); - } else { - // 16 color sprite - if (sprite->flags & 1) { - SpriteFilterScaleDown spriteScaler(sprite, &spriteReader); - drawSpriteCore(dest, spriteScaler, sprite); - } else if (sprite->flags & 2) { - SpriteFilterScaleUp spriteScaler(sprite, &spriteReader); - drawSpriteCore(dest, spriteScaler, sprite); - } else { - drawSpriteCore(dest, spriteReader, sprite); - } - } - - debug(0, "Screen::drawSprite() ok"); - -} - -void Screen::drawSpriteCore(byte *dest, SpriteFilter &reader, SpriteDrawItem *sprite) { - - int16 destInc; - - if (sprite->flags & 4) { - destInc = -1; - dest += sprite->width; - } else { - destInc = 1; - } - - SpriteReaderStatus status; - PixelPacket packet; - - byte *destp = dest; - int16 skipX = sprite->skipX; - - int16 w = sprite->width; - int16 h = sprite->height; - - do { - status = reader.readPacket(packet); - - if (skipX > 0) { - while (skipX > 0) { - skipX -= packet.count; - if (skipX < 0) { - packet.count = ABS(skipX); - break; - } - status = reader.readPacket(packet); - } - } - - if (w - packet.count < 0) - packet.count = w; - - w -= packet.count; - - if (((sprite->flags & 0x40) && (packet.pixel != 0)) || - ((sprite->flags & 0x10) && (packet.pixel != 0xFF)) || - !(sprite->flags & 0x10) && (packet.pixel != 0)) - { - if (sprite->flags & 0x40) { - while (packet.count--) { - *dest = _vm->_palette->getColorTransPixel(*dest); - dest += destInc; - } - } else { - if (sprite->flags & 0x10) { - packet.pixel = ((packet.pixel << 4) & 0xF0) | ((packet.pixel >> 4) & 0x0F); - } else { - packet.pixel += sprite->baseColor - 1; - } - while (packet.count--) { - *dest = packet.pixel; - dest += destInc; - } - } - } else { - dest += packet.count * destInc; - } - - if (status == kSrsEndOfLine || w <= 0) { - if (w <= 0) { - while (status == kSrsPixelsLeft) { - status = reader.readPacket(packet); - } - } - dest = destp + 640; - destp = dest; - skipX = sprite->skipX; - w = sprite->width; - h--; - } - - } while (status != kSrsEndOfSprite && h > 0); - -} - -void Screen::drawSprites() { - for (Common::List<SpriteDrawItem>::iterator iter = _spriteDrawList.begin(); iter != _spriteDrawList.end(); iter++) { - SpriteDrawItem *sprite = &(*iter); - drawSprite(sprite); - _vm->_segmap->restoreMasksBySprite(sprite); - } -} - void Screen::updateVerbLine(int16 slotIndex, int16 slotOffset) { debug(0, "Screen::updateVerbLine() _verbLineNum = %d; _verbLineX = %d; _verbLineY = %d; _verbLineWidth = %d; _verbLineCount = %d", |