annotate Weather.cpp @ 2458:d53da932f594

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