Mercurial > mm7
annotate Weather.cpp @ 2438:c10c639f8365
* Fixed releasing movie for movie-less transitions.
author | a.parshin |
---|---|
date | Thu, 24 Jul 2014 00:31:49 +0300 |
parents | f4af3b203f65 |
children |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
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
|
5 #define _CRT_SECURE_NO_WARNINGS |
0 | 6 #include <stdlib.h> |
7 | |
8 #include "Weather.h" | |
9 #include "Viewport.h" | |
10 #include "Render.h" | |
11 | |
1262 | 12 #include "mm7_data.h" ////TODO: remove this once LOWORD/HIWRD stuff is refactored |
0 | 13 |
14 | |
15 | |
16 | |
17 struct Weather *pWeather = new Weather; | |
18 | |
19 | |
20 | |
21 //----- (004C2AA6) -------------------------------------------------------- | |
22 int Weather::DrawSnow() | |
23 { | |
24 | |
2121 | 25 // if (!FORCE_16_BITS) |
26 // __debugbreak(); // function expects 16bit target buffer, will fail otherwise | |
27 for ( uint i = 0; i < 700; ++i ) | |
0 | 28 { |
2121 | 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 | |
0 | 34 { |
2121 | 35 if ( this->Screen_Coord[x] < (signed int)viewparams->uScreen_topL_X )//8 |
36 this->Screen_Coord[x] = viewparams->uScreen_BttmR_X - rand() % 8; | |
0 | 37 } |
38 else | |
2121 | 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 | |
0 | 42 { |
2121 | 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)); | |
0 | 45 } |
2121 | 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(снежинка - точка) | |
0 | 48 } |
2121 | 49 |
50 for ( uint i = 700; i < 950; ++i ) | |
0 | 51 { |
2121 | 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) ) | |
0 | 61 { |
2121 | 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)); | |
0 | 64 } |
2121 | 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) ) | |
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 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 | 86 { |
2121 | 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)); | |
0 | 89 } |
2121 | 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 | |
0 | 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 | |
692 | 139 v3 = pViewport->uScreen_BR_X - pViewport->uScreen_TL_X - 4; |
140 v4 = pViewport->uScreen_BR_Y - pViewport->uScreen_TL_Y - 4; | |
2121 | 141 for ( uint i = 0; i < 1000; i++ ) |
0 | 142 { |
2121 | 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; | |
0 | 145 } |
146 return 0; | |
147 } | |
148 | |
149 //----- (004C2EFA) -------------------------------------------------------- | |
150 int Weather::Draw() | |
151 { | |
2277 | 152 if ( bRenderSnow || bSnow ) |
0 | 153 DrawSnow(); |
154 return 0; | |
155 } | |
156 | |
157 //----- (004C2F0B) -------------------------------------------------------- | |
271 | 158 bool Weather::OnPlayerTurn(__int16 a2) |
0 | 159 { |
160 unsigned int screen_width; // esi@3 | |
161 | |
2121 | 162 if ( this->bRenderSnow != true ) |
0 | 163 return 0; |
692 | 164 screen_width = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X; |
0 | 165 |
2121 | 166 for ( uint i = 0; i < 1000; ++i ) |
0 | 167 { |
2121 | 168 this->Screen_Coord[2 * i] += a2; |
169 if ( this->Screen_Coord[2 * i] < (signed int)viewparams->uScreen_BttmR_X - 4 ) | |
0 | 170 { |
2121 | 171 if ( this->Screen_Coord[2 * i] >= (signed int)viewparams->uScreen_topL_X ) |
172 continue; | |
173 this->Screen_Coord[2 * i] += screen_width; | |
0 | 174 } |
175 else | |
2121 | 176 this->Screen_Coord[2 * i] = this->Screen_Coord[2 * i] - screen_width + 4; |
0 | 177 } |
2121 | 178 return 1; |
0 | 179 } |