aboutsummaryrefslogtreecommitdiff
path: root/engines/parallaction/graphics.h
blob: e409f8a714321f032828290746e8d45431895c05 (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
/* ScummVM - Scumm Interpreter
 * Copyright (C) 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 PARALLACTION_GRAPHICS_H
#define PARALLACTION_GRAPHICS_H

#include "parallaction/defs.h"

namespace Parallaction {



#define SCREEN_WIDTH		320
#define SCREEN_HEIGHT		200
#define SCREEN_SIZE 		SCREEN_WIDTH*SCREEN_HEIGHT

#define SCREENMASK_WIDTH	SCREEN_WIDTH/4
#define SCREENPATH_WIDTH	SCREEN_WIDTH/8

#define PALETTE_COLORS		32
#define PALETTE_SIZE		PALETTE_COLORS*3

#pragma pack(push, 1)

struct PaletteFxRange {

	uint16	_timer;
	uint16	_step;
	uint16	_flags;
	byte	_first;
	byte	_last;

};

#pragma pack(pop)

extern byte _palette[];

#define NUM_BUFFERS 6

class Parallaction;

class Graphics {

public:
	enum Buffers {
		// bit buffers
		kBitFront,
		kBitBack,
		kBit2,
		kBit3,
		// mask buffers
		kMask0,
		// path buffers
		kPath0
	};

public:

	// dialogue and text
	void drawBalloon(int16 left, int16 top, uint16 width, uint16 height, uint16 arg_8);
	void displayBalloonString(uint16 x, uint16 y, const char *text, byte color);
	void displayString(uint16 x, uint16 y, const char *text);
	bool displayWrappedString(char *text, uint16 x, uint16 y, uint16 maxwidth, byte color);
	uint16 getStringWidth(const char *text);
	void getStringExtent(char *text, uint16 maxwidth, int16* width, int16* height);

	// cnv management
	void makeCnvFromString(StaticCnv *cnv, char *text);
	void loadExternalCnv(const char *filename, Cnv *cnv);
	void loadExternalStaticCnv(const char *filename, StaticCnv *cnv);
	void loadCnv(const char *filename, Cnv *cnv);
	void loadStaticCnv(const char *filename, StaticCnv *cnv);
	void freeCnv(Cnv *cnv);
	void freeStaticCnv(StaticCnv *cnv);
	void backupCnvBackground(StaticCnv *cnv, int16 x, int16 y);
	void backupCnvBackgroundTransparent(StaticCnv *cnv, int16 x, int16 y);
	void restoreCnvBackground(StaticCnv *cnv, int16 x, int16 y);

	// location
	void loadBackground(const char *filename, Graphics::Buffers buffer);
	void loadMaskAndPath(const char *filename);
	uint16 queryPath(uint16 x, uint16 y);
	int16 queryMask(int16 v);
	void intGrottaHackMask();
	void restoreBackground(int16 left, int16 top, uint16 width, uint16 height);
	void backupBackgroundMask(Graphics::Buffers mask);
	void restoreBackgroundMask(Graphics::Buffers mask);
	void backupBackgroundPath(Graphics::Buffers path);
	void restoreBackgroundPath(Graphics::Buffers path);

	// intro
	void maskClearRectangle(uint16 left, uint16 top, uint16 right, uint16 bottom, Graphics::Buffers mask);
	void maskOpNot(uint16 x, uint16 y, uint16 unused, Graphics::Buffers mask);

	// low level
	void swapBuffers();
	void updateScreen();
	void clearScreen(Graphics::Buffers buffer);
	void copyScreen(Graphics::Buffers srcbuffer, Graphics::Buffers dstbuffer);
	void copyRect(Graphics::Buffers srcbuffer, uint16 sx, uint16 sy, Graphics::Buffers dstbuffer, uint16 dx, uint16 dy, uint16 w, uint16 h);
	void copyRect(Graphics::Buffers dstbuffer, uint16 x, uint16 y, uint16 w, uint16 h, byte *src, uint16 pitch);
	void grabRect(Graphics::Buffers srcbuffer, byte *dst, uint16 x, uint16 y, uint16 w, uint16 h, uint16 pitch);
	void drawBorder(Graphics::Buffers buffer, uint16 x, uint16 y, uint16 w, uint16 h, byte color);
	void floodFill(byte color, uint16 left, uint16 top, uint16 right, uint16 bottom, Graphics::Buffers buffer);
	void flatBlitCnv(StaticCnv *cnv, int16 x, int16 y, Graphics::Buffers buffer, byte *unused);
	void blitCnv(StaticCnv *cnv, int16 x, int16 y, uint16 z, Graphics::Buffers buffer, Graphics::Buffers mask);

	// palette
	void animatePalette(byte *palette);
	void setPalette(byte *palette);
	void getBlackPalette(byte *palette);
	void palUnk0(byte *palette);
	void buildBWPalette(byte *palette);
	void quickFadePalette(byte *palette);
	void fadePalette(byte *palette);

	// init
	Graphics(Parallaction* vm);
	virtual ~Graphics();

	void setMousePointer(int16 index);


public:
	static Point		_labelPosition[2];
	static bool 		_proportionalFont;
	static Cnv			_font;

protected:
	Parallaction*		_vm;

	static byte *		_buffers[NUM_BUFFERS];

	static byte			_mouseArrow[256];
	static StaticCnv	_mouseComposedArrow;

protected:
	//
	//	decompress a graphics block (size is *target* size)
	//
	//	returns amount of byte read
	//
	uint16 decompressChunk(byte *src, byte *dst, uint16 size);

	//
	//	maps a character for representation
	//
	char mapChar(char c);

	void flatBlit(uint16 w, uint16 h, int16 x, int16 y, byte *data, Graphics::Buffers buffer);
	void blit(uint16 w, uint16 h, int16 x, int16 y, uint16 z, byte *data, Graphics::Buffers buffer, Graphics::Buffers mask);


	void initBuffers();
	void initMouse(uint16 arg_0);


};


} // Parallaction


#endif