annotate Weather.cpp @ 2391:5d866ee28376

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