ScummVM API documentation
graphics.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 AGI_GRAPHICS_H
23#define AGI_GRAPHICS_H
24
25#include "agi/font.h"
26
27namespace Agi {
28
29#define SCRIPT_WIDTH 160
30#define SCRIPT_HEIGHT 168
31#define VISUAL_WIDTH 160
32#define VISUAL_HEIGHT 200
33#define DISPLAY_DEFAULT_WIDTH 320
34#define DISPLAY_DEFAULT_HEIGHT 200
35
36enum GfxScreenUpscaledMode {
37 DISPLAY_UPSCALED_DISABLED = 0,
38 DISPLAY_UPSCALED_640x400 = 1
39};
40
41class AgiBase;
42
43enum GfxScreenMasks {
44 GFX_SCREEN_MASK_VISUAL = 1,
45 GFX_SCREEN_MASK_PRIORITY = 2,
46 GFX_SCREEN_MASK_ALL = GFX_SCREEN_MASK_VISUAL | GFX_SCREEN_MASK_PRIORITY
47};
48
50 const byte *bitmapData;
51 byte *bitmapDataAllocated;
52 uint16 width;
53 uint16 height;
54 int hotspotX;
55 int hotspotY;
56};
57
58class GfxMgr {
59private:
60 AgiBase *_vm;
61 GfxFont *_font;
62
63 uint8 _paletteGfxMode[256 * 3];
64 uint8 _paletteTextMode[256 * 3];
65
66 uint8 _agipalPalette[16 * 3];
67 int _agipalFileNum;
68
69public:
70 GfxMgr(AgiBase *vm, GfxFont *font);
71
72 void initVideo();
73 void deinitVideo();
74 static void initPalette(uint8 *destPalette, const uint8 *paletteData, uint colorCount = 16, uint fromBits = 6, uint toBits = 8);
75 static void initPaletteCLUT(uint8 *destPalette, const uint16 *paletteCLUTData, uint colorCount = 16);
76 void setAGIPal(int);
77 int getAGIPalFileNum() const;
78 void setPalette(bool GfxModePalette);
79
80 void initMouseCursor(MouseCursorData *mouseCursor, const byte *bitmapData, uint16 width, uint16 height, int hotspotX, int hotspotY);
81 void setMouseCursor(bool busy = false);
82
83 void setRenderStartOffset(uint16 offsetY);
84 uint16 getRenderStartDisplayOffsetY() const;
85
86 void translateGamePosToDisplayScreen(int16 &x, int16 &y) const;
87 void translateVisualPosToDisplayScreen(int16 &x, int16 &y) const;
88 void translateDisplayPosToGameScreen(int16 &x, int16 &y) const;
89
90 void translateVisualDimensionToDisplayScreen(int16 &width, int16 &height) const;
91 void translateDisplayDimensionToVisualScreen(int16 &width, int16 &height) const;
92
93 void translateGameRectToDisplayScreen(int16 &x, int16 &y, int16 &width, int16 &height) const;
94 void translateVisualRectToDisplayScreen(int16 &x, int16 &y, int16 &width, int16 &height) const;
95
96 uint32 getDisplayOffsetToGameScreenPos(int16 x, int16 y) const;
97 uint32 getDisplayOffsetToVisualScreenPos(int16 x, int16 y) const;
98
99 void copyDisplayRectToScreen(int16 x, int16 y, int16 width, int16 height);
100 void copyDisplayRectToScreen(int16 x, int16 adjX, int16 y, int16 adjY, int16 width, int16 adjWidth, int16 height, int16 adjHeight);
101 void copyDisplayRectToScreenUsingGamePos(int16 x, int16 y, int16 width, int16 height);
102 void copyDisplayRectToScreenUsingVisualPos(int16 x, int16 y, int16 width, int16 height);
103 void copyDisplayToScreen();
104
105 void translateFontPosToDisplayScreen(int16 &x, int16 &y) const;
106 void translateDisplayPosToFontScreen(int16 &x, int16 &y) const;
107 void translateFontDimensionToDisplayScreen(int16 &width, int16 &height) const;
108 void translateFontRectToDisplayScreen(int16 &x, int16 &y, int16 &width, int16 &height) const;
109 Common::Rect getFontRectForDisplayScreen(int16 column, int16 row, int16 width, int16 height) const;
110
111private:
112 uint _pixels;
113 uint _displayPixels;
114
115 byte *_activeScreen;
116 byte *_gameScreen; // 160x168 - screen, where the actual game content is drawn to (actual graphics, not including status line, prompt, etc.)
117 byte *_priorityScreen; // 160x168 - screen contains priority information of the game screen
118 // the term "visual screen" is effectively the display screen, but at 160x200 resolution. Used for coordinate translation
119 byte *_displayScreen; // 320x200 or 640x400 - screen, that the game is rendered to and which is then copied to framebuffer
120
121 uint16 _displayScreenWidth;
122 uint16 _displayScreenHeight;
123
124 uint16 _displayFontWidth;
125 uint16 _displayFontHeight;
126
127 uint16 _displayWidthMulAdjust;
128 uint16 _displayHeightMulAdjust;
129
134 GfxScreenUpscaledMode _upscaledHires;
135
136 bool _priorityTableSet;
137 uint8 _priorityTable[SCRIPT_HEIGHT];
139 MouseCursorData _mouseCursor;
140 MouseCursorData _mouseCursorBusy;
141
142 uint16 _renderStartVisualOffsetY;
143 uint16 _renderStartDisplayOffsetY;
144
145public:
146 uint16 getDisplayScreenWidth() const {
147 return _displayScreenWidth;
148 }
149 uint16 getDisplayFontWidth() const {
150 return _displayFontWidth;
151 }
152 uint16 getDisplayFontHeight() const {
153 return _displayFontHeight;
154 }
155
156 GfxScreenUpscaledMode getUpscaledHires() const {
157 return _upscaledHires;
158 }
159
160 void debugShowMap(int mapNr);
161
162 void clear(byte color, byte priority);
163 void clearDisplay(byte color, bool copyToScreen = true);
164 void putPixel(int16 x, int16 y, byte drawMask, byte color, byte priority);
165 void putPixelOnDisplay(int16 x, int16 y, byte color);
166 void putPixelOnDisplay(int16 x, int16 adjX, int16 y, int16 adjY, byte color);
167 void putFontPixelOnDisplay(int16 baseX, int16 baseY, int16 addX, int16 addY, byte color, bool isHires);
168
169 byte getColor(int16 x, int16 y) const;
170 byte getPriority(int16 x, int16 y) const;
171 bool checkControlPixel(int16 x, int16 y, byte newPriority) const;
172
173 byte getCGAMixtureColor(byte color) const;
174
175 void render_Block(int16 x, int16 y, int16 width, int16 height, bool copyToScreen = true);
176
177private:
178 static bool render_Clip(int16 &x, int16 &y, int16 &width, int16 &height, const int16 minY, const int16 clipAgainstWidth, const int16 clipAgainstHeight);
179 void render_BlockEGA(int16 x, int16 y, int16 width, int16 height);
180 void render_BlockCGA(int16 x, int16 y, int16 width, int16 height);
181 void render_BlockHercules(int16 x, int16 y, int16 width, int16 height);
182
183public:
184 void transition_Amiga();
185 void transition_AtariSt();
186
187 void block_save(int16 x, int16 y, int16 width, int16 height, byte *bufferPtr) const;
188 void block_restore(int16 x, int16 y, int16 width, int16 height, byte *bufferPtr);
189
190 void drawBox(int16 x, int16 y, int16 width, int16 height, byte backgroundColor, byte lineColor);
191 void drawDisplayRect(int16 x, int16 y, int16 width, int16 height, byte color, bool copyToScreen = true);
192 void drawDisplayRect(int16 x, int16 adjX, int16 y, int16 adjY, int16 width, int16 adjWidth, int16 height, int16 adjHeight, byte color, bool copyToScreen = true);
193private:
194 void drawDisplayRectEGA(int16 x, int16 y, int16 width, int16 height, byte color);
195 void drawDisplayRectCGA(int16 x, int16 y, int16 width, int16 height, byte color);
196
197public:
198 void drawCharacter(int16 row, int16 column, byte character, byte foreground, byte background, bool disabledLook);
199 void drawStringOnDisplay(int16 x, int16 y, const char *text, byte foreground, byte background);
200 void drawStringOnDisplay(int16 x, int16 adjX, int16 y, int16 adjY, const char *text, byte foregroundColor, byte backgroundColor);
201 void drawCharacterOnDisplay(int16 x, int16 y, byte character, byte foreground, byte background, byte transformXOR = 0, byte transformOR = 0);
202
203 void shakeScreen(int16 repeatCount);
204 void updateScreen();
205
206 void initPriorityTable();
207 static void createDefaultPriorityTable(uint8 *priorityTable);
208 void setPriorityTable(int16 priorityBase);
209 bool saveLoadWasPriorityTableModified() const;
210 int16 saveLoadGetPriority(int16 yPos) const;
211 void saveLoadSetPriorityTableModifiedBool(bool wasModified);
212 void saveLoadSetPriority(int16 yPos, int16 priority);
213 void saveLoadFigureOutPriorityTableModifiedBool();
214
215 int16 priorityToY(int16 priority) const;
216 int16 priorityFromY(int16 yPos) const;
217};
218
219} // End of namespace Agi
220
221#endif /* AGI_GRAPHICS_H */
Definition: agi.h:573
Definition: font.h:27
Definition: graphics.h:58
Definition: agi.h:64
Definition: graphics.h:49
Definition: rect.h:536