1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef SCI_GRAPHICS_VIEW_H 24 #define SCI_GRAPHICS_VIEW_H 25 26 #include "sci/util.h" 27 28 namespace Sci { 29 30 struct CelInfo { 31 int16 width, height; 32 int16 scriptWidth, scriptHeight; 33 int16 displaceX; 34 int16 displaceY; 35 byte clearKey; 36 uint16 offsetEGA; 37 uint32 offsetRLE; 38 uint32 offsetLiteral; 39 Common::SpanOwner<SciSpan<const byte> > rawBitmap; 40 }; 41 42 struct LoopInfo { 43 bool mirrorFlag; 44 Common::Array<CelInfo> cel; 45 }; 46 47 enum { 48 SCI_VIEW_EGAMAPPING_SIZE = 16, 49 SCI_VIEW_EGAMAPPING_COUNT = 8 50 }; 51 52 class GfxScreen; 53 class GfxPalette; 54 class Resource; 55 56 /** 57 * View class, handles loading of view resources and drawing contained cels to screen 58 * every view resource has its own instance of this class 59 */ 60 class GfxView { 61 public: 62 GfxView(ResourceManager *resMan, GfxScreen *screen, GfxPalette *palette, GuiResourceId resourceId); 63 ~GfxView(); 64 65 GuiResourceId getResourceId() const; 66 int16 getWidth(int16 loopNo, int16 celNo) const; 67 int16 getHeight(int16 loopNo, int16 celNo) const; 68 const CelInfo *getCelInfo(int16 loopNo, int16 celNo) const; 69 void getCelRect(int16 loopNo, int16 celNo, int16 x, int16 y, int16 z, Common::Rect &outRect) const; 70 void getCelSpecialHoyle4Rect(int16 loopNo, int16 celNo, int16 x, int16 y, int16 z, Common::Rect &outRect) const; 71 void getCelScaledRect(int16 loopNo, int16 celNo, int16 x, int16 y, int16 z, int16 scaleX, int16 scaleY, Common::Rect &outRect) const; 72 const SciSpan<const byte> &getBitmap(int16 loopNo, int16 celNo); 73 void draw(const Common::Rect &rect, const Common::Rect &clipRect, const Common::Rect &clipRectTranslated, int16 loopNo, int16 celNo, byte priority, uint16 EGAmappingNr, bool upscaledHires, uint16 scaleSignal = 0); 74 void drawScaled(const Common::Rect &rect, const Common::Rect &clipRect, const Common::Rect &clipRectTranslated, int16 loopNo, int16 celNo, byte priority, int16 scaleX, int16 scaleY, uint16 scaleSignal = 0); getLoopCount()75 uint16 getLoopCount() const { return _loop.size(); } 76 uint16 getCelCount(int16 loopNo) const; 77 Palette *getPalette(); 78 79 bool isScaleable(); 80 81 void adjustToUpscaledCoordinates(int16 &y, int16 &x); 82 void adjustBackUpscaledCoordinates(int16 &y, int16 &x); 83 84 private: 85 void initData(GuiResourceId resourceId); 86 void unpackCel(int16 loopNo, int16 celNo, SciSpan<byte> &outPtr); 87 void unditherBitmap(SciSpan<byte> &bitmap, int16 width, int16 height, byte clearKey); 88 byte getMappedColor(byte color, uint16 scaleSignal, const Palette *palette, int x2, int y2); 89 90 static void createScalingTable(Common::Array<uint16> &table, int16 celSize, uint16 maxSize, int16 scale); 91 92 ResourceManager *_resMan; 93 GfxCoordAdjuster16 *_coordAdjuster; 94 GfxScreen *_screen; 95 GfxPalette *_palette; 96 97 GuiResourceId _resourceId; 98 Resource *_resource; 99 100 Common::Array<LoopInfo> _loop; 101 bool _embeddedPal; 102 Palette _viewPalette; 103 104 SciSpan<const byte> _EGAmapping; 105 106 // this is set for sci0early to adjust for the getCelRect() change 107 int16 _adjustForSci0Early; 108 109 // this is not set for some views in laura bow 2 floppy and signals that the view shall never get scaled 110 // even if scaleX/Y are set (inside kAnimate) 111 bool _isScaleable; 112 }; 113 114 } // End of namespace Sci 115 116 #endif 117