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