0
|
1 #include <stdlib.h>
|
|
2
|
|
3 #include "Weather.h"
|
|
4 #include "Viewport.h"
|
|
5 #include "Render.h"
|
|
6
|
|
7 #include "mm7_data.h"
|
|
8
|
|
9
|
|
10
|
|
11
|
80
|
12 struct Weather *pWeather = new Weather;
|
0
|
13
|
|
14
|
|
15
|
|
16 //----- (004C2AA6) --------------------------------------------------------
|
|
17 int Weather::DrawSnow()
|
|
18 {
|
|
19 unsigned __int16 *v1; // edi@1
|
|
20 __int16 *v2; // esi@2
|
|
21 int v3; // eax@2
|
|
22 signed int v4; // eax@6
|
|
23 int v5; // edx@8
|
|
24 __int16 *v6; // esi@11
|
|
25 __int16 *v7; // eax@11
|
|
26 int v8; // ecx@11
|
|
27 int v9; // eax@12
|
|
28 int v10; // ecx@16
|
|
29 int v11; // edx@18
|
|
30 Weather *v12; // eax@20
|
|
31 __int16 *v13; // esi@20
|
|
32 int v14; // eax@21
|
|
33 int v15; // eax@21
|
|
34 int v16; // edx@23
|
|
35 int v17; // eax@24
|
|
36 int v18; // edx@26
|
|
37 int v19; // ecx@27
|
|
38 int v20; // eax@27
|
|
39 char v21; // zf@27
|
|
40 unsigned int v23; // [sp+Ch] [bp-20h]@1
|
|
41 unsigned int v24; // [sp+10h] [bp-1Ch]@1
|
|
42 unsigned int v25; // [sp+14h] [bp-18h]@1
|
|
43 Weather *v26; // [sp+18h] [bp-14h]@1
|
|
44 signed int v27; // [sp+18h] [bp-14h]@20
|
|
45 unsigned int v28; // [sp+1Ch] [bp-10h]@1
|
|
46 unsigned int v29; // [sp+20h] [bp-Ch]@1
|
|
47 __int16 *v30; // [sp+24h] [bp-8h]@2
|
|
48 signed int v31; // [sp+28h] [bp-4h]@1
|
|
49 signed int v32; // [sp+28h] [bp-4h]@10
|
|
50
|
|
51 v26 = this;
|
|
52 v25 = viewparams->uScreenZ;
|
|
53 v28 = viewparams->uScreenY;
|
|
54 v31 = 0;
|
|
55 v1 = pRenderer->pTargetSurface;
|
|
56 v29 = viewparams->uScreenX;
|
|
57 v23 = viewparams->uScreenW;
|
|
58 v24 = viewparams->uScreenZ - viewparams->uScreenX;
|
|
59 do
|
|
60 {
|
|
61 v2 = &v26->field_0[2 * v31];
|
|
62 v30 = &v26->field_0[2 * v31 + 1];
|
|
63 *v2 += rand() % 3 + 1;
|
|
64 *v30 += rand() % 2 + 1;
|
|
65 v3 = *v2;
|
|
66 if ( v3 < (signed int)(v25 - 1) )
|
|
67 {
|
|
68 if ( v3 < (signed int)v29 )
|
|
69 *v2 = v25 - rand() % 8;
|
|
70 }
|
|
71 else
|
|
72 {
|
|
73 *v2 = v29 + rand() % 8;
|
|
74 }
|
|
75 v4 = *v30;
|
|
76 if ( v4 < (signed int)v28 || v4 >= (signed int)v23 )
|
|
77 {
|
|
78 v5 = rand() % (signed int)(v24 - 2);
|
|
79 *v30 = v28;
|
|
80 *v2 = v29 + v5;
|
|
81 }
|
|
82 ++v31;
|
|
83 v1[*v2 + 640 * *v30] = 0xFFFFu;
|
|
84 }
|
|
85 while ( v31 < 700 );
|
|
86 v32 = 700;
|
|
87 do
|
|
88 {
|
|
89 v6 = &v26->field_0[2 * v32];
|
|
90 *v6 += rand() % 5 - 3;
|
|
91 v7 = &v26->field_0[2 * v32 + 1];
|
|
92 v8 = *v6;
|
|
93 *v7 += 4;
|
|
94 if ( v8 < (signed int)v29 )
|
|
95 {
|
|
96 LOWORD(v9) = v25 - rand() % 4 - 2;
|
|
97 LABEL_15:
|
|
98 *v6 = v9;
|
|
99 v7 = &v26->field_0[2 * v32 + 1];
|
|
100 goto LABEL_16;
|
|
101 }
|
|
102 if ( v8 >= (signed int)(v25 - 2) )
|
|
103 {
|
|
104 v9 = rand() % 4 + v29 + 2;
|
|
105 goto LABEL_15;
|
|
106 }
|
|
107 LABEL_16:
|
|
108 v10 = *v7;
|
|
109 if ( v10 < (signed int)v28 || v10 >= (signed int)(v23 - 1) )
|
|
110 {
|
|
111 v11 = rand() % (signed int)(v24 - 2);
|
|
112 v26->field_0[2 * v32 + 1] = v28;
|
|
113 v7 = &v26->field_0[2 * v32 + 1];
|
|
114 *v6 = v29 + v11;
|
|
115 }
|
|
116 *(&v1[640 * *v7 + 1] + *v6) = 0xFFFFu;
|
|
117 *(&v1[640 * *v7 + 641] + *v6) = 0xFFFFu;
|
|
118 v1[*v6 + 640 * (*v7 + 1)] = 0xFFFFu;
|
|
119 ++v32;
|
|
120 v1[*v6 + 640 * *v7] = 0xFFFFu;
|
|
121 }
|
|
122 while ( v32 < 950 );
|
|
123 v12 = v26;
|
|
124 v27 = 50;
|
|
125 v13 = &v12->field_0[1901];
|
|
126 do
|
|
127 {
|
|
128 v14 = rand();
|
|
129 *v13 += 8;
|
|
130 *(v13 - 1) += v14 % 11 - 5;
|
|
131 v15 = *(v13 - 1);
|
|
132 if ( v15 < (signed int)v29 || v15 >= (signed int)(v25 - 5) )
|
|
133 {
|
|
134 v16 = rand() % (signed int)(v24 - 5);
|
|
135 *v13 = v28;
|
|
136 *(v13 - 1) = v29 + v16;
|
|
137 }
|
|
138 v17 = *v13;
|
|
139 if ( v17 < (signed int)v28 || v17 >= (signed int)(v23 - 5) )
|
|
140 {
|
|
141 v18 = rand() % (signed int)(v24 - 5);
|
|
142 *v13 = v28;
|
|
143 *(v13 - 1) = v29 + v18;
|
|
144 }
|
|
145 *(&v1[640 * *v13 + 1] + *(v13 - 1)) = 0xFFFFu;
|
|
146 *(&v1[640 * *v13 + 641] + *(v13 - 1)) = 0xFFFFu;
|
|
147 v1[*(v13 - 1) + 640 * (*v13 + 1)] = 0xFFFFu;
|
|
148 v1[*(v13 - 1) + 640 * *v13] = 0xFFFFu;
|
|
149 *(&v1[640 * *v13 + 1281] + *(v13 - 1)) = 0xFFFFu;
|
|
150 *(&v1[640 * *v13 + 1921] + *(v13 - 1)) = 0xFFFFu;
|
|
151 v1[*(v13 - 1) + 640 * (*v13 + 3)] = 0xFFFFu;
|
|
152 v1[*(v13 - 1) + 640 * (*v13 + 2)] = 0xFFFFu;
|
|
153 *(&v1[640 * *v13 + 3] + *(v13 - 1)) = 0xFFFFu;
|
|
154 *(&v1[640 * *v13 + 643] + *(v13 - 1)) = 0xFFFFu;
|
|
155 *(&v1[640 * *v13 + 642] + *(v13 - 1)) = 0xFFFFu;
|
|
156 *(&v1[640 * *v13 + 2] + *(v13 - 1)) = 0xFFFFu;
|
|
157 *(&v1[640 * *v13 + 1283] + *(v13 - 1)) = 0xFFFFu;
|
|
158 *(&v1[640 * *v13 + 1923] + *(v13 - 1)) = 0xFFFFu;
|
|
159 *(&v1[640 * *v13 + 1922] + *(v13 - 1)) = 0xFFFFu;
|
|
160 v19 = *(v13 - 1);
|
|
161 v20 = 5 * *v13;
|
|
162 v13 += 2;
|
|
163 v21 = v27-- == 1;
|
|
164 *(&v1[128 * v20 + 1282] + v19) = 0xFFFFu;
|
|
165 }
|
|
166 while ( !v21 );
|
|
167 return 0;
|
|
168 }
|
|
169
|
|
170 //----- (004C2EA0) --------------------------------------------------------
|
|
171 int Weather::Initialize()
|
|
172 {
|
|
173 Weather *v1; // edi@1
|
|
174 signed int v2; // esi@1
|
|
175 signed int v3; // ebx@1
|
|
176 signed int v4; // ebp@1
|
|
177
|
|
178 v1 = this;
|
|
179 v2 = 0;
|
|
180 v3 = pViewport->uScreenZ - pViewport->uScreenX - 4;
|
|
181 v4 = pViewport->uScreenW - pViewport->uScreenY - 4;
|
|
182 do
|
|
183 {
|
|
184 v1->field_0[2 * v2++] = LOWORD(pViewport->uViewportX) + rand() % v3;
|
|
185 *((short *)v1 + 2 * v2 - 1) = LOWORD(pViewport->uViewportY) + rand() % v4;
|
|
186 }
|
|
187 while ( v2 < 1000 );
|
|
188 return 0;
|
|
189 }
|
|
190
|
|
191 //----- (004C2EFA) --------------------------------------------------------
|
|
192 int Weather::Draw()
|
|
193 {
|
|
194 if (bRenderSnow)
|
|
195 DrawSnow();
|
|
196 return 0;
|
|
197 }
|
|
198
|
|
199 //----- (004C2F0B) --------------------------------------------------------
|
|
200 bool Weather::_4C2F0B(__int16 a2)
|
|
201 {
|
|
202 int v3; // edx@3
|
|
203 signed int v4; // ebx@3
|
|
204 unsigned int screen_width; // esi@3
|
|
205 __int16 *v6; // eax@5
|
|
206 signed int v7; // edi@5
|
|
207 unsigned int screen_x; // [sp+0h] [bp-Ch]@3
|
|
208 unsigned int screen_z_minus_4; // [sp+4h] [bp-8h]@3
|
|
209 Weather *v10; // [sp+8h] [bp-4h]@1
|
|
210
|
|
211 v10 = this;
|
|
212 if ( this->bRenderSnow != 1 )
|
|
213 return 0;
|
|
214 HIWORD(v3) = HIWORD(viewparams->uScreenX);
|
|
215 v4 = 0;
|
|
216 screen_width = viewparams->uScreenZ - viewparams->uScreenX;
|
|
217 screen_x = viewparams->uScreenX;
|
|
218 screen_z_minus_4 = viewparams->uScreenZ - 4;
|
|
219
|
|
220 auto _this = this->field_0;
|
|
221 while ( 1 )
|
|
222 {
|
|
223 v6 = &_this[2 * v4];
|
|
224 *v6 += a2;
|
|
225 LOWORD(v3) = *v6;
|
|
226 v7 = *v6;
|
|
227 if ( v7 < (signed int)screen_z_minus_4 )
|
|
228 {
|
|
229 if ( v7 >= (signed int)screen_x )
|
|
230 goto LABEL_10;
|
|
231 v3 += screen_width;
|
|
232 }
|
|
233 else
|
|
234 {
|
|
235 v3 = v3 - screen_width + 4;
|
|
236 }
|
|
237 *v6 = v3;
|
|
238 LABEL_10:
|
|
239 ++v4;
|
|
240 if ( v4 >= 1000 )
|
|
241 return 1;
|
|
242 //_this = v10;
|
|
243 }
|
|
244 } |