annotate Weather.cpp @ 2151:92511cd8fcdb

Cleaned some variables.
author Nomad
date Wed, 08 Jan 2014 22:29:11 +0200
parents f6e59446c133
children d28d3c006077
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 unsigned __int16 *v1; // edi@1
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
2069
259df09dfb50 32bits almost there
Nomad
parents: 1980
diff changeset
23 v1 = (unsigned __int16 *)pRenderer->pTargetSurface;
2121
Ritor1
parents: 2069
diff changeset
24 for ( uint i = 0; i < 700; ++i )
0
Ritor1
parents:
diff changeset
25 {
2121
Ritor1
parents: 2069
diff changeset
26 int x = 2 * i;
Ritor1
parents: 2069
diff changeset
27 int y = 2 * i + 1;
Ritor1
parents: 2069
diff changeset
28 this->Screen_Coord[x] += rand() % 3 + 1;
Ritor1
parents: 2069
diff changeset
29 this->Screen_Coord[y] += rand() % 2 + 1;
Ritor1
parents: 2069
diff changeset
30 if ( this->Screen_Coord[x] < (signed int)(viewparams->uScreen_BttmR_X - 1) )//467
0
Ritor1
parents:
diff changeset
31 {
2121
Ritor1
parents: 2069
diff changeset
32 if ( this->Screen_Coord[x] < (signed int)viewparams->uScreen_topL_X )//8
Ritor1
parents: 2069
diff changeset
33 this->Screen_Coord[x] = viewparams->uScreen_BttmR_X - rand() % 8;
0
Ritor1
parents:
diff changeset
34 }
Ritor1
parents:
diff changeset
35 else
2121
Ritor1
parents: 2069
diff changeset
36 this->Screen_Coord[x] = viewparams->uScreen_topL_X + rand() % 8;
Ritor1
parents: 2069
diff changeset
37 if ( this->Screen_Coord[y] < (signed int)viewparams->uScreen_topL_Y//8
Ritor1
parents: 2069
diff changeset
38 || this->Screen_Coord[y] >= (signed int)viewparams->uScreen_BttmR_Y )//351
0
Ritor1
parents:
diff changeset
39 {
2121
Ritor1
parents: 2069
diff changeset
40 this->Screen_Coord[y] = viewparams->uScreen_topL_Y;
Ritor1
parents: 2069
diff changeset
41 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
42 }
2121
Ritor1
parents: 2069
diff changeset
43 //v1[this->Screen_Coord[2 * i] + 640 * this->Screen_Coord[2 * i + 1]] = 0xFFFFu;
Ritor1
parents: 2069
diff changeset
44 pRenderer->WritePixel16(this->Screen_Coord[x], this->Screen_Coord[y], 0xFFFF);//snowflake - point(снежинка - точка)
0
Ritor1
parents:
diff changeset
45 }
2121
Ritor1
parents: 2069
diff changeset
46
Ritor1
parents: 2069
diff changeset
47 for ( uint i = 700; i < 950; ++i )
0
Ritor1
parents:
diff changeset
48 {
2121
Ritor1
parents: 2069
diff changeset
49 int x = 2 * i;
Ritor1
parents: 2069
diff changeset
50 int y = 2 * i + 1;
Ritor1
parents: 2069
diff changeset
51 this->Screen_Coord[x] += rand() % 5 - 3;//x
Ritor1
parents: 2069
diff changeset
52 this->Screen_Coord[y] += 4;//y
Ritor1
parents: 2069
diff changeset
53 if ( this->Screen_Coord[x] < (signed int)viewparams->uScreen_topL_X )
Ritor1
parents: 2069
diff changeset
54 this->Screen_Coord[x] = viewparams->uScreen_BttmR_X - rand() % 4 - 2;
Ritor1
parents: 2069
diff changeset
55 if ( this->Screen_Coord[x] >= (signed int)(viewparams->uScreen_BttmR_X - 2) )
Ritor1
parents: 2069
diff changeset
56 this->Screen_Coord[x] = rand() % 4 + viewparams->uScreen_topL_X + 2;
Ritor1
parents: 2069
diff changeset
57 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
58 {
2121
Ritor1
parents: 2069
diff changeset
59 this->Screen_Coord[y] = viewparams->uScreen_topL_Y;
Ritor1
parents: 2069
diff changeset
60 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
61 }
2121
Ritor1
parents: 2069
diff changeset
62 pRenderer->WritePixel16(this->Screen_Coord[x], this->Screen_Coord[y], 0xFFFF);//x, y квадратная снежинка)
Ritor1
parents: 2069
diff changeset
63 pRenderer->WritePixel16(this->Screen_Coord[x] + 1, this->Screen_Coord[y], 0xFFFF);//x + 1, y
Ritor1
parents: 2069
diff changeset
64 pRenderer->WritePixel16(this->Screen_Coord[x], this->Screen_Coord[y] + 1, 0xFFFF);//x , y + 1
Ritor1
parents: 2069
diff changeset
65 pRenderer->WritePixel16(this->Screen_Coord[x] + 1, this->Screen_Coord[y] + 1, 0xFFFF);//x + 1, y + 1
Ritor1
parents: 2069
diff changeset
66
Ritor1
parents: 2069
diff changeset
67 //v1[this->Screen_Coord[2 * i] + 640 * this->Screen_Coord[2 * i + 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] + 1)] = 0xFFFFu;
Ritor1
parents: 2069
diff changeset
70 //v1[this->Screen_Coord[2 * i] + 640 * this->Screen_Coord[2 * i + 1] + 641] = 0xFFFFu;
Ritor1
parents: 2069
diff changeset
71 }
Ritor1
parents: 2069
diff changeset
72
Ritor1
parents: 2069
diff changeset
73 for ( uint i = 0; i < 50; i++)
Ritor1
parents: 2069
diff changeset
74 {
Ritor1
parents: 2069
diff changeset
75 this->Screen_Coord[1901 + (i * 2)] += 8;
Ritor1
parents: 2069
diff changeset
76 this->Screen_Coord[1901 + ((i * 2) -1)] += rand() % 11 - 5;
Ritor1
parents: 2069
diff changeset
77 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
78 {
2121
Ritor1
parents: 2069
diff changeset
79 this->Screen_Coord[1901 + (i * 2)] = viewparams->uScreen_topL_Y;
Ritor1
parents: 2069
diff changeset
80 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
81 }
2121
Ritor1
parents: 2069
diff changeset
82 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
83 {
2121
Ritor1
parents: 2069
diff changeset
84 this->Screen_Coord[1901 + (i * 2)] = viewparams->uScreen_topL_Y;
Ritor1
parents: 2069
diff changeset
85 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
86 }
2121
Ritor1
parents: 2069
diff changeset
87 pRenderer->WritePixel16(this->Screen_Coord[1901 + ((i * 2) -1)], this->Screen_Coord[1901 + (i * 2)], 0xFFFF);//x, y
Ritor1
parents: 2069
diff changeset
88 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
89 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
90 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
91
Ritor1
parents: 2069
diff changeset
92 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
93 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
94 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
95 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
96
Ritor1
parents: 2069
diff changeset
97 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
98 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
99 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
100 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
101
Ritor1
parents: 2069
diff changeset
102 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
103 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
104 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
105 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
106
Ritor1
parents: 2069
diff changeset
107 //v1[this->Screen_Coord[1901 + ((i * 2) -1)] + 640 * this->Screen_Coord[1901 + (i * 2)]] = 0xFFFFu;//x, y
Ritor1
parents: 2069
diff changeset
108 //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
109 //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
110 //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
111
Ritor1
parents: 2069
diff changeset
112 //*(&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
113 //*(&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
114 //*(&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
115 //*(&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
116
Ritor1
parents: 2069
diff changeset
117 //*(&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
118 //*(&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
119 //*(&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
120 //*(&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
121
Ritor1
parents: 2069
diff changeset
122 //*(&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
123 //*(&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
124 //*(&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
125 //*(&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
126 }
Ritor1
parents:
diff changeset
127 return 0;
Ritor1
parents:
diff changeset
128 }
Ritor1
parents:
diff changeset
129
Ritor1
parents:
diff changeset
130 //----- (004C2EA0) --------------------------------------------------------
Ritor1
parents:
diff changeset
131 int Weather::Initialize()
Ritor1
parents:
diff changeset
132 {
Ritor1
parents:
diff changeset
133 signed int v3; // ebx@1
Ritor1
parents:
diff changeset
134 signed int v4; // ebp@1
Ritor1
parents:
diff changeset
135
692
066e2b29b30f viewport.cpp added
Gloval
parents: 271
diff changeset
136 v3 = pViewport->uScreen_BR_X - pViewport->uScreen_TL_X - 4;
066e2b29b30f viewport.cpp added
Gloval
parents: 271
diff changeset
137 v4 = pViewport->uScreen_BR_Y - pViewport->uScreen_TL_Y - 4;
2121
Ritor1
parents: 2069
diff changeset
138 for ( uint i = 0; i < 1000; i++ )
0
Ritor1
parents:
diff changeset
139 {
2121
Ritor1
parents: 2069
diff changeset
140 this->Screen_Coord[2 * i] = LOWORD(pViewport->uViewportTL_X) + rand() % v3;
Ritor1
parents: 2069
diff changeset
141 this->Screen_Coord[(2 * (i + 1)) - 1] = LOWORD(pViewport->uViewportTL_Y) + rand() % v4;
0
Ritor1
parents:
diff changeset
142 }
Ritor1
parents:
diff changeset
143 return 0;
Ritor1
parents:
diff changeset
144 }
Ritor1
parents:
diff changeset
145
Ritor1
parents:
diff changeset
146 //----- (004C2EFA) --------------------------------------------------------
Ritor1
parents:
diff changeset
147 int Weather::Draw()
Ritor1
parents:
diff changeset
148 {
Ritor1
parents:
diff changeset
149 if (bRenderSnow)
Ritor1
parents:
diff changeset
150 DrawSnow();
Ritor1
parents:
diff changeset
151 return 0;
Ritor1
parents:
diff changeset
152 }
Ritor1
parents:
diff changeset
153
Ritor1
parents:
diff changeset
154 //----- (004C2F0B) --------------------------------------------------------
271
1f0af5cac2dd _42ECB5_PlayerAttacksActor
Nomad
parents: 0
diff changeset
155 bool Weather::OnPlayerTurn(__int16 a2)
0
Ritor1
parents:
diff changeset
156 {
Ritor1
parents:
diff changeset
157 unsigned int screen_width; // esi@3
Ritor1
parents:
diff changeset
158
2121
Ritor1
parents: 2069
diff changeset
159 if ( this->bRenderSnow != true )
0
Ritor1
parents:
diff changeset
160 return 0;
692
066e2b29b30f viewport.cpp added
Gloval
parents: 271
diff changeset
161 screen_width = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X;
0
Ritor1
parents:
diff changeset
162
2121
Ritor1
parents: 2069
diff changeset
163 for ( uint i = 0; i < 1000; ++i )
0
Ritor1
parents:
diff changeset
164 {
2121
Ritor1
parents: 2069
diff changeset
165 this->Screen_Coord[2 * i] += a2;
Ritor1
parents: 2069
diff changeset
166 if ( this->Screen_Coord[2 * i] < (signed int)viewparams->uScreen_BttmR_X - 4 )
0
Ritor1
parents:
diff changeset
167 {
2121
Ritor1
parents: 2069
diff changeset
168 if ( this->Screen_Coord[2 * i] >= (signed int)viewparams->uScreen_topL_X )
Ritor1
parents: 2069
diff changeset
169 continue;
Ritor1
parents: 2069
diff changeset
170 this->Screen_Coord[2 * i] += screen_width;
0
Ritor1
parents:
diff changeset
171 }
Ritor1
parents:
diff changeset
172 else
2121
Ritor1
parents: 2069
diff changeset
173 this->Screen_Coord[2 * i] = this->Screen_Coord[2 * i] - screen_width + 4;
0
Ritor1
parents:
diff changeset
174 }
2121
Ritor1
parents: 2069
diff changeset
175 return 1;
0
Ritor1
parents:
diff changeset
176 }