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 MADE_SCREEN_H 24 #define MADE_SCREEN_H 25 26 #include "made/resource.h" 27 28 #include "common/rect.h" 29 30 namespace Made { 31 32 struct SpriteChannel { 33 int16 type; 34 int16 state; 35 uint16 index; 36 int16 x, y; 37 uint16 fontNum; 38 int16 textColor, outlineColor; 39 int16 frameNum; 40 int16 mask; 41 }; 42 43 struct ClipInfo { 44 Common::Rect clipRect; 45 Graphics::Surface *destSurface; 46 }; 47 48 struct SpriteListItem { 49 int16 index, xofs, yofs; 50 }; 51 52 class MadeEngine; 53 class ScreenEffects; 54 55 static const byte defaultMouseCursor[256] = { 56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 58 0, 0, 0, 0, 0, 0, 0, 1, 15, 15, 1, 0, 0, 0, 0, 0, 59 0, 0, 0, 0, 0, 0, 0, 1, 15, 15, 1, 0, 0, 0, 0, 0, 60 0, 0, 0, 0, 0, 0, 0, 1, 15, 15, 1, 0, 0, 0, 0, 0, 61 0, 1, 1, 1, 1, 1, 1, 1, 15, 15, 1, 0, 0, 0, 0, 0, 62 1, 1, 15, 1, 15, 1, 15, 1, 15, 15, 1, 0, 0, 0, 0, 0, 63 1, 15, 15, 1, 15, 1, 15, 1, 15, 15, 1, 0, 0, 0, 0, 0, 64 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 0, 1, 1, 1, 0, 65 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 15, 15, 15, 1, 66 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 1, 67 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 0, 0, 68 1, 1, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 0, 0, 0, 69 0, 1, 1, 15, 15, 15, 15, 15, 15, 15, 1, 1, 0, 0, 0, 0, 70 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 72 }; 73 74 class Screen { 75 public: 76 Screen(MadeEngine *vm); 77 ~Screen(); 78 79 void clearScreen(); 80 81 void drawSurface(Graphics::Surface *sourceSurface, int x, int y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo); 82 83 void setRGBPalette(byte *palRGB, int start = 0, int count = 256); isPaletteLocked()84 bool isPaletteLocked() { return _paletteLock; } setPaletteLock(bool lock)85 void setPaletteLock(bool lock) { _paletteLock = lock; } isScreenLocked()86 bool isScreenLocked() { return _screenLock; } setScreenLock(bool lock)87 void setScreenLock(bool lock) { _screenLock = lock; } setVisualEffectNum(int visualEffectNum)88 void setVisualEffectNum(int visualEffectNum) { _visualEffectNum = visualEffectNum; } 89 setClipArea(uint16 x1,uint16 y1,uint16 x2,uint16 y2)90 void setClipArea(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { 91 _clipArea.clipRect = Common::Rect(x1, y1, x2, y2); 92 } 93 94 void setExcludeArea(uint16 x1, uint16 y1, uint16 x2, uint16 y2); 95 setClip(int16 clip)96 void setClip(int16 clip) { _clip = clip; } setExclude(int16 exclude)97 void setExclude(int16 exclude) { _exclude = exclude; } setGround(int16 ground)98 void setGround(int16 ground) { _ground = ground; } setMask(int16 mask)99 void setMask(int16 mask) { _mask = mask; } 100 setTextColor(int16 color)101 void setTextColor(int16 color) { _textColor = color; } 102 setTextRect(const Common::Rect & textRect)103 void setTextRect(const Common::Rect &textRect) { 104 _textRect = textRect; 105 _textX = _textRect.left; 106 _textY = _textRect.top; 107 } 108 getTextRect(Common::Rect & textRect)109 void getTextRect(Common::Rect &textRect) { 110 textRect = _textRect; 111 } 112 setOutlineColor(int16 color)113 void setOutlineColor(int16 color) { 114 _outlineColor = color; 115 _dropShadowColor = -1; 116 } 117 setDropShadowColor(int16 color)118 void setDropShadowColor(int16 color) { 119 _outlineColor = -1; 120 _dropShadowColor = color; 121 } 122 setTextXY(int16 x,int16 y)123 void setTextXY(int16 x, int16 y) { 124 _textX = x; 125 _textY = y; 126 } 127 homeText()128 void homeText() { 129 _textX = _textRect.left; 130 _textY = _textRect.top; 131 } 132 133 uint16 updateChannel(uint16 channelIndex); 134 void deleteChannel(uint16 channelIndex); 135 int16 getChannelType(uint16 channelIndex); 136 int16 getChannelState(uint16 channelIndex); 137 void setChannelState(uint16 channelIndex, int16 state); 138 uint16 setChannelLocation(uint16 channelIndex, int16 x, int16 y); 139 uint16 setChannelContent(uint16 channelIndex, uint16 index); 140 void setChannelUseMask(uint16 channelIndex); 141 void drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask, int16 excludeStateMask); 142 void updateSprites(); 143 void clearChannels(); 144 145 uint16 drawFlex(uint16 flexIndex, int16 x, int16 y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo); 146 147 void drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY, const ClipInfo &clipInfo); 148 149 uint16 drawPic(uint16 index, int16 x, int16 y, int16 flipX, int16 flipY); 150 uint16 drawMask(uint16 index, int16 x, int16 y); 151 152 uint16 drawAnimPic(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY); 153 154 void addSprite(uint16 spriteIndex); 155 156 uint16 drawSprite(uint16 flexIndex, int16 x, int16 y); 157 uint16 placeSprite(uint16 channelIndex, uint16 flexIndex, int16 x, int16 y); 158 159 uint16 placeAnim(uint16 channelIndex, uint16 animIndex, int16 x, int16 y, int16 frameNum); 160 int16 setAnimFrame(uint16 channelIndex, int16 frameNum); 161 int16 getAnimFrame(uint16 channelIndex); 162 163 uint16 placeText(uint16 channelIndex, uint16 textObjectIndex, int16 x, int16 y, uint16 fontNum, int16 textColor, int16 outlineColor); 164 165 void show(); 166 void flash(int count); 167 168 void setFont(int16 fontNum); 169 void printChar(uint c, int16 x, int16 y, byte color); 170 void printText(const char *text); 171 void printTextEx(const char *text, int16 x, int16 y, int16 fontNum, int16 textColor, int16 outlineColor, const ClipInfo &clipInfo); 172 void printObjectText(int16 objectIndex, int16 x, int16 y, int16 fontNum, int16 textColor, int16 outlineColor, const ClipInfo &clipInfo); 173 int16 getTextWidth(int16 fontNum, const char *text); 174 175 // Interface functions for the screen effects class 176 Graphics::Surface *lockScreen(); 177 void unlockScreen(); 178 void showWorkScreen(); 179 void copyRectToScreen(const void *buf, int pitch, int x, int y, int w, int h); 180 void updateScreenAndWait(int delay); 181 182 int16 addToSpriteList(int16 index, int16 xofs, int16 yofs); 183 SpriteListItem getFromSpriteList(int16 index); 184 void clearSpriteList(); 185 186 void setDefaultMouseCursor(); 187 188 protected: 189 MadeEngine *_vm; 190 ScreenEffects *_fx; 191 192 bool _screenLock; 193 bool _paletteLock; 194 195 byte *_palette, *_newPalette; 196 int _paletteColorCount, _oldPaletteColorCount; 197 bool _paletteInitialized, _needPalette; 198 int16 _textColor; 199 int16 _outlineColor; 200 int16 _dropShadowColor; 201 202 int16 _textX, _textY; 203 Common::Rect _textRect; 204 int16 _currentFontNum; 205 FontResource *_font; 206 ClipInfo _fontDrawCtx; 207 208 int16 _clip, _exclude, _ground, _mask; 209 int _visualEffectNum; 210 211 Graphics::Surface *_backgroundScreen, *_workScreen, *_screenMask; 212 ClipInfo _clipArea, _backgroundScreenDrawCtx, _workScreenDrawCtx, _maskDrawCtx; 213 214 ClipInfo _excludeClipArea[4]; 215 bool _excludeClipAreaEnabled[4]; 216 217 uint16 _channelsUsedCount; 218 SpriteChannel _channels[100]; 219 220 Common::Array<SpriteListItem> _spriteList; 221 222 }; 223 224 } // End of namespace Made 225 226 #endif /* MADE_H */ 227