1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef SLUDGE_GRAPHICS_H
#define SLUDGE_GRAPHICS_H
#include "common/stream.h"
#include "graphics/surface.h"
#include "graphics/transparent_surface.h"
#include "sludge/sprbanks.h"
namespace Sludge {
class Parallax;
class SludgeEngine;
class SpritePalette;
struct StackHandler;
struct FrozenStuffStruct;
struct LoadedSpriteBank;
struct OnScreenPerson;
struct SpriteBank;
struct Sprite;
struct SpriteLayers;
struct ZBufferData;
enum ELightMapMode {
LIGHTMAPMODE_NONE = -1,
LIGHTMAPMODE_HOTSPOT,
LIGHTMAPMODE_PIXEL,
LIGHTMAPMODE_NUM
};
class GraphicsManager {
public:
GraphicsManager(SludgeEngine *vm);
virtual ~GraphicsManager();
// graphics
void setWindowSize(uint winWidth, uint winHeight) { _winWidth = winWidth; _winHeight = winHeight; }
bool init();
void display();
void clear();
// Parallax
bool loadParallax(uint16 v, uint16 fracX, uint16 fracY);
void killParallax();
void saveParallax(Common::WriteStream *fp);
void drawParallax();
// Backdrop
void killAllBackDrop();
bool resizeBackdrop(int x, int y);
bool killResizeBackdrop(int x, int y);
void killBackDrop();
void loadBackDrop(int fileNum, int x, int y);
void mixBackDrop(int fileNum, int x, int y);
void drawBackDrop();
void blankScreen(int x1, int y1, int x2, int y2);
void blankAllScreen();
void darkScreen();
void saveHSI(Common::WriteStream *stream);
bool loadHSI(Common::SeekableReadStream *stream, int, int, bool);
bool mixHSI(Common::SeekableReadStream *stream, int x = 0, int y = 0);
void drawLine(uint, uint, uint, uint);
void drawHorizontalLine(uint, uint, uint);
void drawVerticalLine(uint, uint, uint);
void hardScroll(int distance);
bool getRGBIntoStack(uint x, uint y, StackHandler *sH);
// Lightmap
int _lightMapMode;
void killLightMap();
bool loadLightMap(int v);
void saveLightMap(Common::WriteStream *stream);
bool loadLightMap(int ssgVersion, Common::SeekableReadStream *stream);
// Snapshot
void nosnapshot();
bool snapshot();
void saveSnapshot(Common::WriteStream *stream);
bool restoreSnapshot(Common::SeekableReadStream *stream);
// Camera
int getCamX() { return _cameraX; }
int getCamY() { return _cameraY; }
float getCamZoom() { return _cameraZoom; }
void setCamera(int camerX, int camerY, float camerZ) {
_cameraX = camerX;
_cameraY = camerY;
_cameraZoom = camerZ;
}
void aimCamera(int cameraX, int cameraY);
void zoomCamera(int z);
// Screen
int getCenterX(int width) { return (_winWidth - width) >> 1; }
int checkSizeValide(int width, int height) { return ((width >= 0) && (height >= 0) && (width < (int)_winWidth) && (height < (int)_winHeight)); }
// Freeze
bool freeze();
void unfreeze(bool killImage = true);
int howFrozen();
bool isFrozen() { return (_frozenStuff != nullptr); }
// Sprites
void forgetSpriteBank(SpriteBank &forgetme);
bool loadSpriteBank(char *filename, SpriteBank &loadhere);
bool loadSpriteBank(int fileNum, SpriteBank &loadhere, bool isFont);
void fontSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
void flipFontSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
bool scaleSprite(Sprite &single, const SpritePalette &fontPal, OnScreenPerson *thisPerson, bool mirror);
void fixScaleSprite(int x1, int y1, Sprite &single, const SpritePalette &fontPal, OnScreenPerson *thisPerson, const int camX, const int camY, bool);
void pasteSpriteToBackDrop(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
bool reserveSpritePal(SpritePalette &sP, int n);
void burnSpriteToBackDrop(int x1, int y1, Sprite &single, const SpritePalette &fontPal);
void resetSpriteLayers(ZBufferData *ptrZBuffer, int x, int y, bool upsidedown);
void addSpriteDepth(Graphics::Surface *ptr, int depth, int x, int y, Graphics::FLIP_FLAGS flip, int width = -1, int height = -1, bool disposeAfterUse = false);
void displaySpriteLayers();
void killSpriteLayers();
// Sprite Bank
LoadedSpriteBank *loadBankForAnim(int ID);
// ZBuffer
bool setZBuffer(int y);
void killZBuffer();
void drawZBuffer(int x, int y, bool upsidedown);
void saveZBuffer(Common::WriteStream *stream);
bool loadZBuffer(Common::SeekableReadStream *stream);
// Colors
void setBlankColor(int r, int g, int b) { _currentBlankColour = _renderSurface.format.RGBToColor(r & 255, g & 255, b & 255);};
void setBurnColor(int r, int g, int b) {
_currentBurnG = r;
_currentBurnG = g;
_currentBurnB = b;
}
void saveColors(Common::WriteStream *stream);
void loadColors(Common::SeekableReadStream *stream);
// Thumb nail
bool saveThumbnail(Common::WriteStream *stream);
bool skipThumbnail(Common::SeekableReadStream *stream);
void showThumbnail(const Common::String &filename, int x, int y);
private:
SludgeEngine *_vm;
uint _winWidth, _winHeight, _sceneWidth, _sceneHeight;
// renderSurface
Graphics::Surface _renderSurface;
// Snapshot
Graphics::Surface _snapshotSurface;
// LightMap
int _lightMapNumber;
Graphics::Surface _lightMap;
// Parallax
Parallax *_parallaxStuff;
// Camera
float _cameraZoom;
int _cameraX, _cameraY;
// Freeze
FrozenStuffStruct *_frozenStuff;
Graphics::Surface _freezeSurface;
void freezeGraphics();
// Back drop
Graphics::Surface _backdropSurface;
Graphics::Surface _origBackdropSurface;
bool _backdropExists;
bool reserveBackdrop();
// Sprites
SpriteLayers *_spriteLayers;
void fontSprite(bool flip, int x, int y, Sprite &single, const SpritePalette &fontPal);
Graphics::Surface *duplicateSurface(Graphics::Surface *surface);
void blendColor(Graphics::Surface * surface, uint32 color, Graphics::TSpriteBlendMode mode);
Graphics::Surface *applyLightmapToSprite(Graphics::Surface *&blitted, OnScreenPerson *thisPerson, bool mirror, int x, int y, int x1, int y1, int diffX, int diffY);
// Sprite banks
LoadedSpriteBanks _allLoadedBanks;
// ZBuffer
ZBufferData *_zBuffer;
void sortZPal(int *oldpal, int *newpal, int size);
// Colors
uint _currentBlankColour;
byte _currentBurnR, _currentBurnG, _currentBurnB;
};
} // End of namespace Sludge
#endif // SLUDGE_GRAPHICS_H
|