1 /*
2  * Seven Kingdoms: Ancient Adversaries
3  *
4  * Copyright 1997,1998 Enlight Software Ltd.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 // Filename    : OFLAME.H
22 // Description : header file of class Flame
23 // Ownership   : Gilbert
24 
25 #ifndef __OFLAME_H
26 #define __OFLAME_H
27 
28 //---------- define constant -------//
29 #define FLAME_GROW_STEP 4
30 
31 enum FlameType
32 {
33 	FLAME_CENTRE_POINT,
34 	FLAME_RANDOM_POINTS,
35 	FLAME_WIDE
36 };
37 
38 //-------- define class Flame ----------//
39 
40 class VgaBuf;
41 
42 class Flame
43 {
44 public:
45 	unsigned char* heat_map;				// array of size map_width * map_height
46 	unsigned char* bitmap;					// array of size map_width * map_height +4
47 													// to be drawn by IMGbltTrans and IMGbltAreaTrans
48 	unsigned seed;
49 	short	map_width;
50 	short map_height;
51 	short decay;
52 	short smooth;
53 	short shade_base;							// init -1, changed after gen_bitmap
54 
55 	// parameter for init and displaying flame[0], flame[1]...
56 public:
grade(int flameStr)57 	static int grade(int flameStr)				{ return (FLAME_GROW_STEP * flameStr)/(20+ flameStr); }
default_width(int flameGrade)58 	static int default_width(int flameGrade)	{ return flameGrade*8+40; }
default_height(int flameGrade)59 	static int default_height(int flameGrade)	{ return flameGrade*12+28; }
offset_x(int flameGrade)60 	static int offset_x(int flameGrade)			{ return -4-4*flameGrade; }	// (ZOOM_LOC_HEIGHT - Flame::default_width)/2
offset_y(int flameGrade)61 	static int offset_y(int flameGrade)			{ return 4-flameGrade*12; }	// ZOOM_LOC_WIDTH - Flame::default_height
base_width(int flameGrade)62 	static int base_width(int flameGrade)		{ return flameGrade *2 +4; }
63 
64 public:
65 	Flame();
66 	Flame(short width, short height, short flameWidth, FlameType);
67 	~Flame();
68 
69 	void init(short width, short height, short flameWidth, FlameType);
70 	void deinit();
71 
72 	Flame& operator= (Flame &);
73 	void heat_up(short);
74 	void rise(short wind);				// -1 to +1
75 	void gen_bitmap(unsigned char shadeColor = 0xb4);
76 	void mask_bottom();
77 	void mask_transparent();
78 	void draw_step(short left, short bottom, VgaBuf *vgabuf, short wind); // coordinate of left and bottom
79 	void flush_point(short x=-1, short y=-1);
80 
81 private:
82 	unsigned random(unsigned);
83 
84 };
85 
86 extern Flame flame[FLAME_GROW_STEP];
87 
88 #endif