0
|
1 #include <stdlib.h>
|
|
2
|
|
3 #include "Weather.h"
|
|
4 #include "Viewport.h"
|
|
5 #include "Render.h"
|
|
6
|
1262
|
7 #include "mm7_data.h" ////TODO: remove this once LOWORD/HIWRD stuff is refactored
|
0
|
8
|
|
9
|
|
10
|
|
11
|
|
12 struct Weather *pWeather = new Weather;
|
|
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;
|
692
|
52 v25 = viewparams->uScreen_BttmR_X;
|
|
53 v28 = viewparams->uScreen_topL_Y;
|
0
|
54 v31 = 0;
|
2069
|
55 if (!FORCE_16_BITS)
|
|
56 __debugbreak(); // function expects 16bit target buffer, will fail otherwise
|
|
57 v1 = (unsigned __int16 *)pRenderer->pTargetSurface;
|
692
|
58 v29 = viewparams->uScreen_topL_X;
|
|
59 v23 = viewparams->uScreen_BttmR_Y;
|
|
60 v24 = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X;
|
0
|
61 do
|
|
62 {
|
|
63 v2 = &v26->field_0[2 * v31];
|
|
64 v30 = &v26->field_0[2 * v31 + 1];
|
|
65 *v2 += rand() % 3 + 1;
|
|
66 *v30 += rand() % 2 + 1;
|
|
67 v3 = *v2;
|
|
68 if ( v3 < (signed int)(v25 - 1) )
|
|
69 {
|
|
70 if ( v3 < (signed int)v29 )
|
|
71 *v2 = v25 - rand() % 8;
|
|
72 }
|
|
73 else
|
|
74 {
|
|
75 *v2 = v29 + rand() % 8;
|
|
76 }
|
|
77 v4 = *v30;
|
|
78 if ( v4 < (signed int)v28 || v4 >= (signed int)v23 )
|
|
79 {
|
|
80 v5 = rand() % (signed int)(v24 - 2);
|
|
81 *v30 = v28;
|
|
82 *v2 = v29 + v5;
|
|
83 }
|
|
84 ++v31;
|
|
85 v1[*v2 + 640 * *v30] = 0xFFFFu;
|
|
86 }
|
|
87 while ( v31 < 700 );
|
|
88 v32 = 700;
|
|
89 do
|
|
90 {
|
|
91 v6 = &v26->field_0[2 * v32];
|
|
92 *v6 += rand() % 5 - 3;
|
|
93 v7 = &v26->field_0[2 * v32 + 1];
|
|
94 v8 = *v6;
|
|
95 *v7 += 4;
|
|
96 if ( v8 < (signed int)v29 )
|
|
97 {
|
|
98 LOWORD(v9) = v25 - rand() % 4 - 2;
|
|
99 LABEL_15:
|
|
100 *v6 = v9;
|
|
101 v7 = &v26->field_0[2 * v32 + 1];
|
|
102 goto LABEL_16;
|
|
103 }
|
|
104 if ( v8 >= (signed int)(v25 - 2) )
|
|
105 {
|
|
106 v9 = rand() % 4 + v29 + 2;
|
|
107 goto LABEL_15;
|
|
108 }
|
|
109 LABEL_16:
|
|
110 v10 = *v7;
|
|
111 if ( v10 < (signed int)v28 || v10 >= (signed int)(v23 - 1) )
|
|
112 {
|
|
113 v11 = rand() % (signed int)(v24 - 2);
|
|
114 v26->field_0[2 * v32 + 1] = v28;
|
|
115 v7 = &v26->field_0[2 * v32 + 1];
|
|
116 *v6 = v29 + v11;
|
|
117 }
|
|
118 *(&v1[640 * *v7 + 1] + *v6) = 0xFFFFu;
|
|
119 *(&v1[640 * *v7 + 641] + *v6) = 0xFFFFu;
|
|
120 v1[*v6 + 640 * (*v7 + 1)] = 0xFFFFu;
|
|
121 ++v32;
|
|
122 v1[*v6 + 640 * *v7] = 0xFFFFu;
|
|
123 }
|
|
124 while ( v32 < 950 );
|
|
125 v12 = v26;
|
|
126 v27 = 50;
|
|
127 v13 = &v12->field_0[1901];
|
|
128 do
|
|
129 {
|
|
130 v14 = rand();
|
|
131 *v13 += 8;
|
|
132 *(v13 - 1) += v14 % 11 - 5;
|
|
133 v15 = *(v13 - 1);
|
|
134 if ( v15 < (signed int)v29 || v15 >= (signed int)(v25 - 5) )
|
|
135 {
|
|
136 v16 = rand() % (signed int)(v24 - 5);
|
|
137 *v13 = v28;
|
|
138 *(v13 - 1) = v29 + v16;
|
|
139 }
|
|
140 v17 = *v13;
|
|
141 if ( v17 < (signed int)v28 || v17 >= (signed int)(v23 - 5) )
|
|
142 {
|
|
143 v18 = rand() % (signed int)(v24 - 5);
|
|
144 *v13 = v28;
|
|
145 *(v13 - 1) = v29 + v18;
|
|
146 }
|
|
147 *(&v1[640 * *v13 + 1] + *(v13 - 1)) = 0xFFFFu;
|
|
148 *(&v1[640 * *v13 + 641] + *(v13 - 1)) = 0xFFFFu;
|
|
149 v1[*(v13 - 1) + 640 * (*v13 + 1)] = 0xFFFFu;
|
|
150 v1[*(v13 - 1) + 640 * *v13] = 0xFFFFu;
|
|
151 *(&v1[640 * *v13 + 1281] + *(v13 - 1)) = 0xFFFFu;
|
|
152 *(&v1[640 * *v13 + 1921] + *(v13 - 1)) = 0xFFFFu;
|
|
153 v1[*(v13 - 1) + 640 * (*v13 + 3)] = 0xFFFFu;
|
|
154 v1[*(v13 - 1) + 640 * (*v13 + 2)] = 0xFFFFu;
|
|
155 *(&v1[640 * *v13 + 3] + *(v13 - 1)) = 0xFFFFu;
|
|
156 *(&v1[640 * *v13 + 643] + *(v13 - 1)) = 0xFFFFu;
|
|
157 *(&v1[640 * *v13 + 642] + *(v13 - 1)) = 0xFFFFu;
|
|
158 *(&v1[640 * *v13 + 2] + *(v13 - 1)) = 0xFFFFu;
|
|
159 *(&v1[640 * *v13 + 1283] + *(v13 - 1)) = 0xFFFFu;
|
|
160 *(&v1[640 * *v13 + 1923] + *(v13 - 1)) = 0xFFFFu;
|
|
161 *(&v1[640 * *v13 + 1922] + *(v13 - 1)) = 0xFFFFu;
|
|
162 v19 = *(v13 - 1);
|
|
163 v20 = 5 * *v13;
|
|
164 v13 += 2;
|
|
165 v21 = v27-- == 1;
|
|
166 *(&v1[128 * v20 + 1282] + v19) = 0xFFFFu;
|
|
167 }
|
|
168 while ( !v21 );
|
|
169 return 0;
|
|
170 }
|
|
171
|
|
172 //----- (004C2EA0) --------------------------------------------------------
|
|
173 int Weather::Initialize()
|
|
174 {
|
|
175 Weather *v1; // edi@1
|
|
176 signed int v2; // esi@1
|
|
177 signed int v3; // ebx@1
|
|
178 signed int v4; // ebp@1
|
|
179
|
|
180 v1 = this;
|
|
181 v2 = 0;
|
692
|
182 v3 = pViewport->uScreen_BR_X - pViewport->uScreen_TL_X - 4;
|
|
183 v4 = pViewport->uScreen_BR_Y - pViewport->uScreen_TL_Y - 4;
|
0
|
184 do
|
|
185 {
|
693
|
186 v1->field_0[2 * v2++] = LOWORD(pViewport->uViewportTL_X) + rand() % v3;
|
|
187 *((short *)v1 + 2 * v2 - 1) = LOWORD(pViewport->uViewportTL_Y) + rand() % v4;
|
0
|
188 }
|
|
189 while ( v2 < 1000 );
|
|
190 return 0;
|
|
191 }
|
|
192
|
|
193 //----- (004C2EFA) --------------------------------------------------------
|
|
194 int Weather::Draw()
|
|
195 {
|
|
196 if (bRenderSnow)
|
|
197 DrawSnow();
|
|
198 return 0;
|
|
199 }
|
|
200
|
|
201 //----- (004C2F0B) --------------------------------------------------------
|
271
|
202 bool Weather::OnPlayerTurn(__int16 a2)
|
0
|
203 {
|
|
204 int v3; // edx@3
|
|
205 signed int v4; // ebx@3
|
|
206 unsigned int screen_width; // esi@3
|
|
207 __int16 *v6; // eax@5
|
|
208 signed int v7; // edi@5
|
|
209 unsigned int screen_x; // [sp+0h] [bp-Ch]@3
|
|
210 unsigned int screen_z_minus_4; // [sp+4h] [bp-8h]@3
|
|
211 Weather *v10; // [sp+8h] [bp-4h]@1
|
|
212
|
|
213 v10 = this;
|
|
214 if ( this->bRenderSnow != 1 )
|
|
215 return 0;
|
692
|
216 HIWORD(v3) = HIWORD(viewparams->uScreen_topL_X);
|
0
|
217 v4 = 0;
|
692
|
218 screen_width = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X;
|
|
219 screen_x = viewparams->uScreen_topL_X;
|
|
220 screen_z_minus_4 = viewparams->uScreen_BttmR_X - 4;
|
0
|
221
|
1980
|
222 short* _this = this->field_0;
|
0
|
223 while ( 1 )
|
|
224 {
|
|
225 v6 = &_this[2 * v4];
|
|
226 *v6 += a2;
|
|
227 LOWORD(v3) = *v6;
|
|
228 v7 = *v6;
|
|
229 if ( v7 < (signed int)screen_z_minus_4 )
|
|
230 {
|
|
231 if ( v7 >= (signed int)screen_x )
|
|
232 goto LABEL_10;
|
|
233 v3 += screen_width;
|
|
234 }
|
|
235 else
|
|
236 {
|
|
237 v3 = v3 - screen_width + 4;
|
|
238 }
|
|
239 *v6 = v3;
|
|
240 LABEL_10:
|
|
241 ++v4;
|
|
242 if ( v4 >= 1000 )
|
|
243 return 1;
|
|
244 //_this = v10;
|
|
245 }
|
|
246 } |