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
228
229
230
231
232
233
234
235
236
237
238
239
|
/* Copyright (C) 1994-2003 Revolution Software Ltd
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header$
*/
#ifndef D_DRAW_H
#define D_DRAW_H
#include "sword2/driver/driver96.h"
namespace Sword2 {
// This is the maximum mouse cursor size in the SDL backend
#define MAX_MOUSE_W 80
#define MAX_MOUSE_H 80
#define RENDERAVERAGETOTAL 4
#define BLOCKWIDTH 64
#define BLOCKHEIGHT 64
#define MAXLAYERS 5
#define PALTABLESIZE 64 * 64 * 64
// Maximum scaled size of a sprite
#define SCALE_MAXWIDTH 512
#define SCALE_MAXHEIGHT 512
#if !defined(__GNUC__)
#pragma START_PACK_STRUCTS
#endif
struct _mouseAnim {
uint8 runTimeComp; // type of runtime compression used for the
// frame data
uint8 noAnimFrames; // number of frames in the anim
int8 xHotSpot;
int8 yHotSpot;
uint8 mousew;
uint8 mouseh;
} GCC_PACK;
#if !defined(__GNUC__)
#pragma END_PACK_STRUCTS
#endif
class MoviePlayer {
private:
uint8 *_textSurface;
void openTextObject(_movieTextObject *obj);
void closeTextObject(_movieTextObject *obj);
void drawTextObject(_movieTextObject *obj);
public:
MoviePlayer() : _textSurface(NULL) {}
int32 play(char *filename, _movieTextObject *text[], uint8 *musicOut);
};
typedef struct {
byte data[BLOCKWIDTH * BLOCKHEIGHT];
bool transparent;
} BlockSurface;
class Graphics {
friend class MoviePlayer;
private:
byte *_buffer;
int32 _renderCaps;
int8 _renderLevel;
uint8 _menuStatus[2];
byte *_icons[2][RDMENU_MAXPOCKETS];
uint8 _pocketStatus[2][RDMENU_MAXPOCKETS];
uint8 _iconCount;
bool _needFullRedraw;
uint8 _paletteMatch[PALTABLESIZE];
uint8 _fadePalette[256][4];
uint8 _fadeStatus;
int32 _fadeStartTime;
int32 _fadeTotalTime;
byte _mouseData[MAX_MOUSE_W * MAX_MOUSE_H];
uint8 _mouseFrame;
uint8 *_mouseSprite;
struct _mouseAnim *_mouseAnim;
struct _mouseAnim *_luggageAnim;
int32 *_mouseOffsets;
int32 *_luggageOffset;
// Scroll variables. _scrollX and _scrollY hold the current scroll
// position, and _scrollXTarget and _scrollYTarget are the target
// position for the end of the game cycle.
int16 _scrollX;
int16 _scrollY;
int16 _scrollXTarget;
int16 _scrollYTarget;
int16 _scrollXOld;
int16 _scrollYOld;
int16 _parallaxScrollX; // current x offset to link a sprite to the
// parallax layer
int16 _parallaxScrollY; // current y offset to link a sprite to the
// parallax layer
int16 _locationWide;
int16 _locationDeep;
uint16 _layer;
int32 _initialTime;
int32 _startTime;
int32 _totalTime;
int32 _renderAverageTime;
int32 _framesPerGameCycle;
bool _renderTooSlow;
uint8 _xBlocks[MAXLAYERS];
uint8 _yBlocks[MAXLAYERS];
// An array of sub-blocks, one for each of the parallax layers.
BlockSurface **_blockSurfaces[MAXLAYERS];
uint16 _xScale[SCALE_MAXWIDTH];
uint16 _yScale[SCALE_MAXHEIGHT];
uint8 *_lightMask;
void clearIconArea(int menu, int pocket, Common::Rect *r);
void decompressMouse(uint8 *decomp, uint8 *comp, int width, int height, int pitch, int xOff = 0, int yOff = 0);
uint8 getMatch(uint8 r, uint8 g, uint8 b);
void fadeServer(void);
void squashImage(byte *dst, uint16 dstPitch, uint16 dstWidth,
uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth,
uint16 srcHeight, byte *backbuf);
void stretchImage(byte *dst, uint16 dstPitch, uint16 dstWidth,
uint16 dstHeight, byte *src, uint16 srcPitch, uint16 srcWidth,
uint16 srcHeight, byte *backbuf);
void updateRect(Common::Rect *r);
void blitBlockSurface(BlockSurface *s, Common::Rect *r, Common::Rect *clip_rect);
void mirrorSprite(uint8 *dst, uint8 *src, int16 w, int16 h);
int32 decompressRLE256(uint8 *dest, uint8 *source, int32 decompSize);
void unwindRaw16(uint8 *dest, uint8 *source, uint8 blockSize, uint8 *colTable);
int32 decompressRLE16(uint8 *dest, uint8 *source, int32 decompSize, uint8 *colTable);
public:
Graphics(int16 width, int16 height);
// Game screen metrics
int16 _screenWide;
int16 _screenDeep;
uint8 _palCopy[256][4];
int8 getRenderLevel(void);
void setRenderLevel(int8 level);
void clearScene(void);
void processMenu(void);
int32 showMenu(uint8 menu);
int32 hideMenu(uint8 menu);
int32 setMenuIcon(uint8 menu, uint8 pocket, uint8 *icon);
void closeMenuImmediately(void);
void updateDisplay(void);
void setWindowName(const char *windowName);
void setNeedFullRedraw(void);
void setPalette(int16 startEntry, int16 noEntries, uint8 *palette, uint8 setNow);
void updatePaletteMatchTable(uint8 *data);
uint8 quickMatch(uint8 r, uint8 g, uint8 b);
int32 fadeUp(float time = 0.75);
int32 fadeDown(float time = 0.75);
uint8 getFadeStatus(void);
void dimPalette(void);
void waitForFade(void);
int32 setMouseAnim(uint8 *ma, int32 size, int32 mouseFlash);
int32 setLuggageAnim(uint8 *la, int32 size);
int32 animateMouse(void);
void drawMouse(void);
void resetRenderEngine(void);
void setScrollTarget(int16 sx, int16 sy);
void initialiseRenderCycle(void);
void startRenderCycle(void);
bool endRenderCycle(void);
void renderParallax(_parallax *p, int16 layer);
void setLocationMetrics(uint16 w, uint16 h);
int32 initialiseBackgroundLayer(_parallax *p);
void closeBackgroundLayer(void);
void plotPoint(uint16 x, uint16 y, uint8 colour);
void drawLine(int16 x1, int16 y1, int16 x2, int16 y2, uint8 colour);
int32 createSurface(_spriteInfo *s, uint8 **surface);
void drawSurface(_spriteInfo *s, uint8 *surface, Common::Rect *clipRect = NULL);
void deleteSurface(uint8 *surface);
int32 drawSprite(_spriteInfo *s);
int32 openLightMask(_spriteInfo *s);
int32 closeLightMask(void);
};
} // End of namespace Sword2
#endif
|