bool Console::cmdShowSprite(int argc, const char **argv) { View *view = _vm->_viewManager->getView(VIEWID_SCENE); if (view == NULL) DebugPrintf("The scene view isn't currently active\n"); else if (argc < 2) DebugPrintf("Usage: %s resource_name\n", argv[0]); else { char resourceName[20]; strncpy(resourceName, argv[1], 15); resourceName[15] = '\0'; if (!strchr(resourceName, '.')) strcat(resourceName, ".SS"); _vm->_viewManager->moveToFront(view); Common::SeekableReadStream *data = _vm->res()->get(resourceName); SpriteAsset *asset = new SpriteAsset(_vm, data, data->size(), resourceName); _vm->res()->toss(resourceName); RGBList *palData = new RGBList(asset->getColorCount(), asset->getPalette(), true); _vm->_palette->addRange(palData); // Get the scene background surface M4Surface *bg = _vm->_scene->getBackgroundSurface(); // Write the sprite onto the screen int x = 0, y = 0, yMax = 0; for (int index = 0; index < asset->getCount(); index++) { M4Sprite *spr = asset->getFrame(index); spr->translate(palData); // sprite pixel translation if ((x + spr->width() >= bg->width()) && (yMax != 0)) { x = 0; y += yMax; yMax = 0; } if (y >= bg->height()) break; // FIXME: We assume that the transparent color is the color of the top left pixel byte *transparentColor = (byte *)spr->pixels; spr->copyTo(bg, x, y, (int)*transparentColor); x += spr->width(); yMax = MAX(yMax, spr->height()); } view->restore(0, 0, view->width(), view->height()); return false; } return true; }
void MadsSpriteSlots::drawBackground() { // Draw all active sprites onto the background surface for (int i = 0; i < startIndex; ++i) { MadsSpriteSlot &slot = _entries[i]; if (slot.spriteType >= 0) { _owner._dirtyAreas[i].active = false; } else { _owner._dirtyAreas[i].textActive = true; _owner._dirtyAreas.setSpriteSlot(i, slot); if (slot.spriteType == BACKGROUND_SPRITE) { SpriteAsset &spriteSet = getSprite(slot.spriteListIndex); M4Sprite *frame = spriteSet.getFrame((slot.frameNumber & 0x7fff) - 1); int xp = slot.xp; int yp = slot.yp; if (_entries[i].scale != -1) { // Adjust position based on frame size xp -= frame->width() / 2; yp -= frame->height() / 2; } if (slot.depth > 1) { // Draw the frame with depth processing _owner._bgSurface->copyFrom(frame, xp, yp, slot.depth, _owner._depthSurface, 100, frame->getTransparencyIndex()); } else { // No depth, so simply draw the image frame->copyTo(_owner._bgSurface, xp, yp, frame->getTransparencyIndex()); } } } } // Flag any remaining dirty areas as inactive for (uint i = startIndex; i < DIRTY_AREAS_TEXT_DISPLAY_IDX; ++i) _owner._dirtyAreas[i].active = false; }
bool OrionMenuView::loadSprites(const char *seriesName) { Common::SeekableReadStream *data = _vm->res()->get(seriesName); RGB8 *palette; _sprites = new SpriteAsset(_vm, data, data->size(), seriesName); palette = _sprites->getPalette(); _vm->_palette->setPalette(palette, 0, _sprites->getColorCount()); _vm->res()->toss(seriesName); // Update the palette //_vm->setPalette((byte *) _menuPalette, 59, 197); // The first sprite is the menu background M4Sprite *bg = _sprites->getFrame(0); this->setSize(bg->width(), bg->height()); _coords.setWidth(bg->width()); _coords.setHeight(bg->height()); bg->copyTo(this); return true; }