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