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