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
|
2121
|
21 // if (!FORCE_16_BITS)
|
|
22 // __debugbreak(); // function expects 16bit target buffer, will fail otherwise
|
2069
|
23 v1 = (unsigned __int16 *)pRenderer->pTargetSurface;
|
2121
|
24 for ( uint i = 0; i < 700; ++i )
|
0
|
25 {
|
2121
|
26 int x = 2 * i;
|
|
27 int y = 2 * i + 1;
|
|
28 this->Screen_Coord[x] += rand() % 3 + 1;
|
|
29 this->Screen_Coord[y] += rand() % 2 + 1;
|
|
30 if ( this->Screen_Coord[x] < (signed int)(viewparams->uScreen_BttmR_X - 1) )//467
|
0
|
31 {
|
2121
|
32 if ( this->Screen_Coord[x] < (signed int)viewparams->uScreen_topL_X )//8
|
|
33 this->Screen_Coord[x] = viewparams->uScreen_BttmR_X - rand() % 8;
|
0
|
34 }
|
|
35 else
|
2121
|
36 this->Screen_Coord[x] = viewparams->uScreen_topL_X + rand() % 8;
|
|
37 if ( this->Screen_Coord[y] < (signed int)viewparams->uScreen_topL_Y//8
|
|
38 || this->Screen_Coord[y] >= (signed int)viewparams->uScreen_BttmR_Y )//351
|
0
|
39 {
|
2121
|
40 this->Screen_Coord[y] = viewparams->uScreen_topL_Y;
|
|
41 this->Screen_Coord[x] = viewparams->uScreen_topL_X + (rand() % (signed int)((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X) - 2));
|
0
|
42 }
|
2121
|
43 //v1[this->Screen_Coord[2 * i] + 640 * this->Screen_Coord[2 * i + 1]] = 0xFFFFu;
|
|
44 pRenderer->WritePixel16(this->Screen_Coord[x], this->Screen_Coord[y], 0xFFFF);//snowflake - point(снежинка - точка)
|
0
|
45 }
|
2121
|
46
|
|
47 for ( uint i = 700; i < 950; ++i )
|
0
|
48 {
|
2121
|
49 int x = 2 * i;
|
|
50 int y = 2 * i + 1;
|
|
51 this->Screen_Coord[x] += rand() % 5 - 3;//x
|
|
52 this->Screen_Coord[y] += 4;//y
|
|
53 if ( this->Screen_Coord[x] < (signed int)viewparams->uScreen_topL_X )
|
|
54 this->Screen_Coord[x] = viewparams->uScreen_BttmR_X - rand() % 4 - 2;
|
|
55 if ( this->Screen_Coord[x] >= (signed int)(viewparams->uScreen_BttmR_X - 2) )
|
|
56 this->Screen_Coord[x] = rand() % 4 + viewparams->uScreen_topL_X + 2;
|
|
57 if ( this->Screen_Coord[y] < (signed int)viewparams->uScreen_topL_Y || this->Screen_Coord[y] >= (signed int)(viewparams->uScreen_BttmR_Y - 1) )
|
0
|
58 {
|
2121
|
59 this->Screen_Coord[y] = viewparams->uScreen_topL_Y;
|
|
60 this->Screen_Coord[x] = viewparams->uScreen_topL_X + (rand() % (signed int)((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X) - 2));
|
0
|
61 }
|
2121
|
62 pRenderer->WritePixel16(this->Screen_Coord[x], this->Screen_Coord[y], 0xFFFF);//x, y квадратная снежинка)
|
|
63 pRenderer->WritePixel16(this->Screen_Coord[x] + 1, this->Screen_Coord[y], 0xFFFF);//x + 1, y
|
|
64 pRenderer->WritePixel16(this->Screen_Coord[x], this->Screen_Coord[y] + 1, 0xFFFF);//x , y + 1
|
|
65 pRenderer->WritePixel16(this->Screen_Coord[x] + 1, this->Screen_Coord[y] + 1, 0xFFFF);//x + 1, y + 1
|
|
66
|
|
67 //v1[this->Screen_Coord[2 * i] + 640 * this->Screen_Coord[2 * i + 1]] = 0xFFFFu;
|
|
68 //v1[this->Screen_Coord[2 * i] + 640 * this->Screen_Coord[2 * i + 1] + 1] = 0xFFFFu;
|
|
69 //v1[this->Screen_Coord[2 * i] + 640 * (this->Screen_Coord[2 * i + 1] + 1)] = 0xFFFFu;
|
|
70 //v1[this->Screen_Coord[2 * i] + 640 * this->Screen_Coord[2 * i + 1] + 641] = 0xFFFFu;
|
|
71 }
|
|
72
|
|
73 for ( uint i = 0; i < 50; i++)
|
|
74 {
|
|
75 this->Screen_Coord[1901 + (i * 2)] += 8;
|
|
76 this->Screen_Coord[1901 + ((i * 2) -1)] += rand() % 11 - 5;
|
|
77 if ( this->Screen_Coord[1901 + ((i * 2) -1)] < (signed int)viewparams->uScreen_topL_X || this->Screen_Coord[1901 + ((i * 2) -1)] >= (signed int)(viewparams->uScreen_BttmR_X - 5) )
|
0
|
78 {
|
2121
|
79 this->Screen_Coord[1901 + (i * 2)] = viewparams->uScreen_topL_Y;
|
|
80 this->Screen_Coord[1901 + ((i * 2) -1)] = viewparams->uScreen_topL_X + (rand() % (signed int)((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X) - 5));
|
0
|
81 }
|
2121
|
82 if ( this->Screen_Coord[1901 + (i * 2)] < (signed int)viewparams->uScreen_topL_Y || this->Screen_Coord[1901 + (i * 2)] >= (signed int)(viewparams->uScreen_BttmR_Y - 5) )
|
0
|
83 {
|
2121
|
84 this->Screen_Coord[1901 + (i * 2)] = viewparams->uScreen_topL_Y;
|
|
85 this->Screen_Coord[1901 + ((i * 2) -1)] = viewparams->uScreen_topL_X + (rand() % (signed int)((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X) - 5));
|
0
|
86 }
|
2121
|
87 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)], this->Screen_Coord[1901 + (i * 2)], 0xFFFF);//x, y
|
|
88 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)], this->Screen_Coord[1901 + (i * 2)] + 1, 0xFFFF);//x, y + 1
|
|
89 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)], this->Screen_Coord[1901 + (i * 2)] + 2, 0xFFFF);//x, y + 2
|
|
90 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)], this->Screen_Coord[1901 + (i * 2)] + 3, 0xFFFF);//x, y + 3
|
|
91
|
|
92 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 1, this->Screen_Coord[1901 + (i * 2)], 0xFFFF);//x + 1, y
|
|
93 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 1, this->Screen_Coord[1901 + (i * 2)] + 1, 0xFFFF);//x + 1, y + 1
|
|
94 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 1, this->Screen_Coord[1901 + (i * 2)] + 2, 0xFFFF);//x + 1, y + 2
|
|
95 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 1, this->Screen_Coord[1901 + (i * 2)] + 3, 0xFFFF);//x + 1, y + 3
|
|
96
|
|
97 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 2, this->Screen_Coord[1901 + (i * 2)], 0xFFFF);//x + 2, y
|
|
98 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 2, this->Screen_Coord[1901 + (i * 2)] + 1, 0xFFFF);//x + 2, y + 1
|
|
99 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 2, this->Screen_Coord[1901 + (i * 2)] + 2, 0xFFFF);//x + 2, y + 2
|
|
100 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 2, this->Screen_Coord[1901 + (i * 2)] + 3, 0xFFFF);//x + 2, y + 3
|
|
101
|
|
102 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 3, this->Screen_Coord[1901 + (i * 2)], 0xFFFF);//x + 3, y
|
|
103 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 3, this->Screen_Coord[1901 + (i * 2)] + 1, 0xFFFF);//x + 3, y + 1
|
|
104 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 3, this->Screen_Coord[1901 + (i * 2)] + 2, 0xFFFF);//x + 3, y + 2
|
|
105 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)] + 3, this->Screen_Coord[1901 + (i * 2)] + 3, 0xFFFF);//x + 3, y + 3
|
|
106
|
|
107 //v1[this->Screen_Coord[1901 + ((i * 2) -1)] + 640 * this->Screen_Coord[1901 + (i * 2)]] = 0xFFFFu;//x, y
|
|
108 //v1[this->Screen_Coord[1901 + ((i * 2) -1)] + 640 * (this->Screen_Coord[1901 + (i * 2)] + 1)] = 0xFFFFu;//x, y + 1
|
|
109 //v1[this->Screen_Coord[1901 + ((i * 2) -1)] + 640 * (this->Screen_Coord[1901 + (i * 2)] + 2)] = 0xFFFFu;//x, y + 2
|
|
110 //v1[this->Screen_Coord[1901 + ((i * 2) -1)] + 640 * (this->Screen_Coord[1901 + (i * 2)] + 3)] = 0xFFFFu;//x, y + 3
|
|
111
|
|
112 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 1] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y, x + 1
|
|
113 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 641] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 1, x + 1
|
|
114 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 1281] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 2, x + 1
|
|
115 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 1921] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 3, x + 1
|
|
116
|
|
117 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 2] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y, x + 2
|
|
118 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 642] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 1, x + 2
|
|
119 //*(&v1[128 * (5 * this->Screen_Coord[1901 + (i * 2)]) + 1282] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 2, x + 2
|
|
120 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 1922] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 3, x + 2
|
|
121
|
|
122 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 3] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y, x + 3
|
|
123 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 643] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 1, x + 3
|
|
124 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 1283] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 2, x + 3
|
|
125 //*(&v1[640 * this->Screen_Coord[1901 + (i * 2)] + 1923] + this->Screen_Coord[1901 + ((i * 2) -1)]) = 0xFFFFu;//y + 3, x + 3
|
0
|
126 }
|
|
127 return 0;
|
|
128 }
|
|
129
|
|
130 //----- (004C2EA0) --------------------------------------------------------
|
|
131 int Weather::Initialize()
|
|
132 {
|
|
133 signed int v3; // ebx@1
|
|
134 signed int v4; // ebp@1
|
|
135
|
692
|
136 v3 = pViewport->uScreen_BR_X - pViewport->uScreen_TL_X - 4;
|
|
137 v4 = pViewport->uScreen_BR_Y - pViewport->uScreen_TL_Y - 4;
|
2121
|
138 for ( uint i = 0; i < 1000; i++ )
|
0
|
139 {
|
2121
|
140 this->Screen_Coord[2 * i] = LOWORD(pViewport->uViewportTL_X) + rand() % v3;
|
|
141 this->Screen_Coord[(2 * (i + 1)) - 1] = LOWORD(pViewport->uViewportTL_Y) + rand() % v4;
|
0
|
142 }
|
|
143 return 0;
|
|
144 }
|
|
145
|
|
146 //----- (004C2EFA) --------------------------------------------------------
|
|
147 int Weather::Draw()
|
|
148 {
|
|
149 if (bRenderSnow)
|
|
150 DrawSnow();
|
|
151 return 0;
|
|
152 }
|
|
153
|
|
154 //----- (004C2F0B) --------------------------------------------------------
|
271
|
155 bool Weather::OnPlayerTurn(__int16 a2)
|
0
|
156 {
|
|
157 unsigned int screen_width; // esi@3
|
|
158
|
2121
|
159 if ( this->bRenderSnow != true )
|
0
|
160 return 0;
|
692
|
161 screen_width = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X;
|
0
|
162
|
2121
|
163 for ( uint i = 0; i < 1000; ++i )
|
0
|
164 {
|
2121
|
165 this->Screen_Coord[2 * i] += a2;
|
|
166 if ( this->Screen_Coord[2 * i] < (signed int)viewparams->uScreen_BttmR_X - 4 )
|
0
|
167 {
|
2121
|
168 if ( this->Screen_Coord[2 * i] >= (signed int)viewparams->uScreen_topL_X )
|
|
169 continue;
|
|
170 this->Screen_Coord[2 * i] += screen_width;
|
0
|
171 }
|
|
172 else
|
2121
|
173 this->Screen_Coord[2 * i] = this->Screen_Coord[2 * i] - screen_width + 4;
|
0
|
174 }
|
2121
|
175 return 1;
|
0
|
176 } |