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 #ifndef DRAGONS_SCREEN_H
22 #define DRAGONS_SCREEN_H
23 
24 #include "graphics/surface.h"
25 #include "graphics/pixelformat.h"
26 #include "common/scummsys.h"
27 #include "common/rect.h"
28 
29 namespace Dragons {
30 #define DRAGONS_NUM_PALETTES 5
31 #define DRAGONS_ENGINE_SPRITE_100_PERCENT_SCALE 256
32 
33 #define DRAGONS_SCREEN_WIDTH 320
34 #define DRAGONS_SCREEN_HEIGHT 200
35 
36 #define DRAGONS_NUM_FLAT_QUADS 0xf
37 
38 #ifdef SCUMM_BIG_ENDIAN
39  #define WRITE_SCREEN WRITE_BE_UINT16
40  #define READ_SCREEN READ_BE_INT16
41 #else
42  #define WRITE_SCREEN WRITE_LE_UINT16
43  #define READ_SCREEN READ_LE_INT16
44 #endif
45 
46 enum AlphaBlendMode {
47  NONE,
48  NORMAL, // 50% x Back + 50% x Sprite
49  ADDITIVE, // 100% x Back + 100% x Sprite
50  ADDITIVE_50, // 100% x Back + 50% x Sprite
51  SUBTRACTIVE // 100% x Back - 100% x Sprite
52 };
53 
54 struct FlatQuad {
55  uint16 flags;
56  uint16 priorityLayer;
57  Common::Point points[4];
58  uint16 colour;
59 
60  FlatQuad() {
61  flags = 0;
62  priorityLayer = 0;
63  colour = 0;
64  }
65 };
66 
67 class Screen {
68 private:
69  Graphics::PixelFormat _pixelFormat;
70  Graphics::Surface *_backSurface;
71  byte _palettes[DRAGONS_NUM_PALETTES][512];
72  Common::Point _screenShakeOffset;
73  FlatQuad _flatQuads[DRAGONS_NUM_FLAT_QUADS];
74 public:
75  virtual ~Screen();
76 
77  Screen();
78 
79  Graphics::PixelFormat getPixelFormat() { return _pixelFormat; }
80  void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY);
81  void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, Common::Rect srcRect, bool flipX = false, AlphaBlendMode alpha = NONE);
82  void copyRectToSurface8bpp(const Graphics::Surface &srcSurface, const byte *palette, int destX, int destY, Common::Rect srcRect, bool flipX = false, AlphaBlendMode alpha = NONE, uint16 scale = DRAGONS_ENGINE_SPRITE_100_PERCENT_SCALE);
83  void copyRectToSurface8bppWrappedX(const Graphics::Surface &srcSurface, const byte *palette, Common::Rect srcRect, AlphaBlendMode alpha = NONE);
84  void updateScreen();
85  void loadPalette(uint16 paletteNum, const byte *palette);
86  byte *getPalette(uint16 paletteNum);
87  void setPaletteRecord(uint16 paletteNum, uint16 offset, uint16 newValue);
88  void updatePaletteTransparency(uint16 paletteNum, uint16 startOffset, uint16 endOffset, bool isTransparent);
89  void clearScreen();
90  void drawRect(uint16 colour, Common::Rect rect, int id);
91  void fillRect(uint16 colour, Common::Rect rect);
92  Common::Rect clipRectToScreen(int destX, int destY, const Common::Rect rect);
93  Common::Rect clipRectToRect(int destX, int destY, const Common::Rect rect, const Common::Rect containerRect);
94 
95  void setScreenShakeOffset(int16 x, int16 y);
96 
97  void copyRectToSurface8bppWrappedY(const Graphics::Surface &srcSurface, const byte *palette, int yOffset);
98 
99  int16 addFlatQuad(int16 x0, int16 y0, int16 x1, int16 y1, int16 x3, int16 y3, int16 x2, int16 y2, uint16 colour, int16 priorityLayer, uint16 flags);
100  void drawFlatQuads(uint16 priorityLayer);
101  FlatQuad *getFlatQuad(uint16 quadId);
102  void clearAllFlatQuads();
103 
104 private:
105  void copyRectToSurface(const void *buffer, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX, AlphaBlendMode alpha);
106  void copyRectToSurface8bpp(const void *buffer, const byte* palette, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX, AlphaBlendMode alpha);
107  void drawScaledSprite(Graphics::Surface *destSurface, const byte *source, int sourceWidth, int sourceHeight, int destX, int destY, int destWidth, int destHeight, const byte *palette, bool flipX, AlphaBlendMode alpha);
108 };
109 
110 } // End of namespace Dragons
111 
112 #endif //DRAGONS_SCREEN_H
Definition: surface.h:66
Definition: pixelformat.h:138
Definition: rect.h:144
Definition: screen.h:67
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: rect.h:45
Definition: actor.h:26
Definition: screen.h:54