annotate Weather.cpp @ 6:71a230891861

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