aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/draw.h
blob: 40eee165aafe623c870630743059243b8eb97f75 (plain)
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
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004 Ivan Dubrov
 * Copyright (C) 2004-2006 The ScummVM project
 *
 * 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.
 *
 * $URL$
 * $Id$
 *
 */
#ifndef GOB_DRAW_H
#define GOB_DRAW_H

#include "gob/video.h"

namespace Gob {

#define RENDERFLAG_NOINVALIDATE	1
#define RENDERFLAG_CAPTUREPUSH	2
#define RENDERFLAG_CAPTUREPOP	8
#define RENDERFLAG_USEDELTAS 	0x10

class Draw {
public:
	struct FontToSprite {
		int8 sprite;
		int8 base;
		int8 width;
		int8 height;
		FontToSprite() : sprite(0), base(0), width(0), height() {}
	};

	int16 _fontIndex;
	int16 _spriteLeft;
	int16 _spriteTop;
	int16 _spriteRight;
	int16 _spriteBottom;
	int16 _destSpriteX;
	int16 _destSpriteY;
	int16 _backColor;
	int16 _frontColor;
	char _letterToPrint;
	FontToSprite _fontToSprite[4];
	int16 _destSurface;
	int16 _sourceSurface;
	int16 _renderFlags;
	int16 _backDeltaX;
	int16 _backDeltaY;
	Video::FontDesc *_fonts[8];
	char *_textToPrint;
	int16 _transparency;
	Video::SurfaceDesc *_spritesArray[50];
	Video::SurfaceDesc *_bigSpritesParts[50][3];
	uint16 _spritesHeights[50];

	int16 _invalidatedCount;
	int16 _invalidatedTops[30];
	int16 _invalidatedLefts[30];
	int16 _invalidatedRights[30];
	int16 _invalidatedBottoms[30];

	int8 _noInvalidated;
//	int8 doFullFlip; // Never used?!?
	int8 _paletteCleared;

	int16 _cursorIndex;
	int16 _transparentCursor;
	uint32 _cursorTimeKey;

	Video::SurfaceDesc *_backSurface;
	Video::SurfaceDesc *_frontSurface;

	int16 _unusedPalette1[18];
	int16 _unusedPalette2[16];
	Video::Color _vgaPalette[256];
	Video::Color _vgaSmallPalette[16];

	// 0 (00b): No cursor
	// 1 (01b): Cursor would be on _backSurface
	// 2 (10b): Cursor would be on _frontSurface
	// 3 (11b): Cursor would be on _backSurface and _frontSurface
	uint8 _showCursor;

	int16 _cursorX;
	int16 _cursorY;
	int16 _cursorWidth;
	int16 _cursorHeight;

	int16 _cursorXDeltaVar;
	int16 _cursorYDeltaVar;

	Video::SurfaceDesc *_cursorSprites;
	Video::SurfaceDesc *_cursorSpritesBack;
	Video::SurfaceDesc *_scummvmCursor;

	int16 _cursorAnim;
	int8 _cursorAnimLow[40];
	int8 _cursorAnimHigh[40];
	int8 _cursorAnimDelays[40];
	int8 _applyPal;

	int16 _palLoadData1[4];
	int16 _palLoadData2[4];
		
	int16 _word_2E8E2;

	void invalidateRect(int16 left, int16 top, int16 right, int16 bottom);
	void blitInvalidated(void);
	void setPalette(void);
	void clearPalette(void);

	void freeSprite(int16 index);
	void adjustCoords(char adjust, int16 *coord1, int16 *coord2);
	void fillRect(int16 index, int16 left, int16 top, int16 right,
		int16 bottom, int16 color);
	void drawSprite(int16 source, int16 dest, int16 left,
			int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
	void drawSprite(Video::SurfaceDesc * source, int16 dest, int16 left,
			int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
	void drawSprite(int16 source, Video::SurfaceDesc * dest, int16 left,
			int16 top, int16 right, int16 bottom, int16 x, int16 y, int16 transp);
	void drawString(char *str, int16 x, int16 y, int16 color1, int16 color2,
		int16 transp, Video::SurfaceDesc *dest, Video::FontDesc *font);
	void printTextCentered(int16 arg_0, int16 left, int16 top, int16 right,
			int16 bottom, char *str, int16 fontIndex, int16 color);

	virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags) = 0;
	virtual void printText(void) = 0;
	virtual void spriteOperation(int16 operation) = 0;
	virtual void blitCursor(void) = 0;
	virtual void animateCursor(int16 cursor) = 0;

	Draw(GobEngine *vm);
	virtual ~Draw() {};

protected:
	GobEngine *_vm;
};

class Draw_v1 : public Draw {
public:
	virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags);
	virtual void printText(void);
	virtual void spriteOperation(int16 operation);
	virtual void blitCursor(void);
	virtual void animateCursor(int16 cursor);

	Draw_v1(GobEngine *vm);
	virtual ~Draw_v1() {};
};

class Draw_v2 : public Draw_v1 {
public:
	virtual void initBigSprite(int16 index, int16 width, int16 height, int16 flags);
	virtual void printText(void);
	virtual void spriteOperation(int16 operation);
	virtual void blitCursor(void);
	virtual void animateCursor(int16 cursor);

	Draw_v2(GobEngine *vm);
	virtual ~Draw_v2() {};
};

// Draw operations

#define DRAW_BLITSURF	0
#define DRAW_PUTPIXEL	1
#define DRAW_FILLRECT	2
#define DRAW_DRAWLINE	3
#define DRAW_INVALIDATE	4
#define DRAW_LOADSPRITE	5
#define DRAW_PRINTTEXT	6
#define DRAW_DRAWBAR 7
#define DRAW_CLEARRECT	8
#define DRAW_FILLRECTABS 9
#define DRAW_DRAWLETTER	10

}				// End of namespace Gob

#endif	/* __DRAW_H */