1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the AUTHORS
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  *
26  */
27 
28 #ifndef ICB_SET_PC_H
29 #define ICB_SET_PC_H
30 
31 #include "engines/icb/p4_generic.h"
32 #include "engines/icb/gfx/psx_pcdefines.h"
33 #include "engines/icb/gfx/rlp_api.h"
34 #include "engines/icb/common/pc_props.h"
35 #include "engines/icb/common/px_staticlayers.h"
36 
37 namespace ICB {
38 
39 #define WEATHER_SCREEN_WIDTH SCREEN_WIDTH
40 #define WEATHER_HALF_SCREEN_WIDTH (WEATHER_SCREEN_WIDTH / 2)
41 #define WEATHER_SCREEN_HEIGHT SCREEN_DEPTH
42 #define WEATHER_HALF_SCREEN_HEIGHT (WEATHER_SCREEN_HEIGHT / 2)
43 #define WEATHER_SCREEN_DEPTH 512
44 #define WEATHER_HALF_SCREEN_DEPTH (WEATHER_SCREEN_DEPTH / 2)
45 #define WEATHER_MAX_PARTICLES 256
46 
47 #define MAX_PROP_STATES 512
48 #define MAX_CAMERA_PROPS 16
49 
50 #define _MAX_SHADOW_LAYERS_ 4
51 #define WEATHER_NONE 0
52 #define WEATHER_RAIN 1
53 #define WEATHER_SNOW 2
54 
55 extern uint32 bg_buffer_id;
56 extern LRECT full_rect;
57 
58 class _set {
59 	friend void sv_WeatherControls();
60 
61 public:
62 	_set();
63 	~_set();
64 
65 public:
66 	bool8 Init(const char *camera_name, const char *h_camera_name); // camera name
67 	void Init_construction_matrices();
68 	void Init_base_bitmap_buffers();
69 	void ReInit();
70 
71 private:
72 	void Load_props();
73 	void Load_props_old();
74 
75 public:
76 	inline PXcamera &GetCamera();
77 	inline rlp_API *GetPRig();
78 	inline pcStaticLayers *GetStaticLayers();
79 	inline pcPropFile *GetProps();
80 	inline uint8 *GetBackground();
81 	inline uint32 GetPropQty();
82 	inline const char *GetPropName(uint32 n);
83 	inline uint32 GetPropRange(uint32 n);
84 	bool8 DoesPropExist(const char *propName);
85 
OK()86 	int32 OK() { return m_setOk; };
87 	void Reset();
88 	bool8 DoesCameraExist(const char *camera_name, const char *camera_cluster_name);
89 
90 private:
91 	void HackMakeCamera();
92 
93 public: /* Drawing Functions */
94 	void RefreshBackdrop();
95 	void Set_draw(bool8 helper);
96 
GetSetName()97 	const char *GetSetName() const { return set_name; }
98 
99 private:                       /* Member variables .... Move this to private section */
100 	char set_name[MAXPATHLEN];    // the camera name (no url)
101 	char set_url[MAXPATHLEN];     // the full url of the camera
102 	uint32 set_url_hash;         // the hashed url of the camera
103 	char set_cluster[MAXPATHLEN]; // cluster file name
104 	uint32 set_cluster_hash;     // hashed cluster file name
105 	/* Waiting for removal */
106 	char h_set_name[MAXPATHLEN]; // just the hash camera name - not full url
107 	char rvpcm_file_name[MAXPATHLEN]; // Props & Construction Matrix
108 	uint32 rvpcm_file_hash;          // Props & Construction Matrix hash value
109 	char rvcam_file_name[MAXPATHLEN]; // Camera
110 	uint32 rvcam_file_hash;          // Camera hash value
111 	char rvsl_file_name[MAXPATHLEN];  // Static Layers
112 	uint32 rvsl_file_hash;           // Static Layers hash value
113 	char rvbg_file_name[MAXPATHLEN];  // Background
114 	uint32 rvbg_file_hash;           // Background hash value
115 	char rlx_file_name[MAXPATHLEN];   // Poly Lighting rig
116 	uint32 rlx_file_hash;            // Poly Lighting rig hash
117 	void SettleCamera();
118 	/* Waiting for removal */
119 
120 public: /* _ WEATHER _ RAIN _ SNOW _ LIGHTNING _ SPARKLE */
121 	void DrawSparkles();
122 	void DrawWeather();
123 	void InitWeather(int32 type, int32 particleQty, int32 lightning, int32 windX, int32 windY, int32 windZ);
124 
125 private:
126 	int16 m_wParticleX[WEATHER_MAX_PARTICLES]; // -320 - 320
127 	int16 m_wParticleY[WEATHER_MAX_PARTICLES]; // -240 - 240
128 	int16 m_wParticleZ[WEATHER_MAX_PARTICLES]; // -512 - 512
129 	int8 m_wParticleDX[WEATHER_MAX_PARTICLES];
130 	int8 m_wParticleDY[WEATHER_MAX_PARTICLES];
131 	int8 m_wParticleDZ[WEATHER_MAX_PARTICLES];
132 	int32 m_wLightningTimer;
133 	int32 m_wType;
134 	int32 m_wWindX;
135 	int32 m_wWindY;
136 	int32 m_wWindZ;
137 	int32 m_wParticleQty;
138 	int32 m_wLightning;
139 
140 private:
141 	int32 m_setOk;                   // Is The Set OK flag
142 	PXcamera m_camera;             // The camera
143 	_pcSetHeader *m_currentCamera; // All the camera data
144 
145 	pcPropFile *m_props;
146 
147 public: /* Prop Surfaces */
148 	uint32 m_propSurfaceIds[MAX_CAMERA_PROPS];
149 	int32 m_propSurfaces[MAX_PROP_STATES];
150 	int32 m_propResolutions[MAX_CAMERA_PROPS];
151 	int32 m_TotalPropSurfaces;
152 };
153 
GetPRig()154 inline rlp_API *_set::GetPRig() { return (rlp_API *)(((uint8 *)m_currentCamera) + m_currentCamera->lightOffset); }
155 
GetStaticLayers()156 inline pcStaticLayers *_set::GetStaticLayers() { return (pcStaticLayers *)(((uint8 *)m_currentCamera) + m_currentCamera->layerOffset); }
157 
GetProps()158 inline pcPropFile *_set::GetProps() { return m_props; }
159 
GetBackground()160 inline uint8 *_set::GetBackground() { return (uint8 *)(((uint8 *)m_currentCamera) + m_currentCamera->backgroundOffset); }
161 
GetCamera()162 inline PXcamera &_set::GetCamera() { return m_camera; }
163 
GetPropQty()164 inline uint32 _set::GetPropQty() {
165 	// Load the prop file
166 	pcPropFile *propFile = GetProps();
167 	return propFile->GetPropQty();
168 }
169 
GetPropName(uint32 n)170 inline const char *_set::GetPropName(uint32 n) {
171 	// Load the prop file
172 	pcPropFile *propFile = GetProps();
173 	// Get the name of prop n
174 	return propFile->GetProp(n)->GetName();
175 }
176 
GetPropRange(uint32 n)177 inline uint32 _set::GetPropRange(uint32 n) {
178 	// Load the prop file
179 	pcPropFile *propFile = GetProps();
180 	// Get the name of prop n
181 	return propFile->GetProp(n)->GetStateQty();
182 }
183 
184 } // End of namespace ICB
185 
186 #endif
187