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