annotate Weather.cpp @ 2190:0acbf1f82c70

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