692
|
1 #include "Viewport.h"
|
|
2
|
|
3 #include "Party.h"
|
|
4 #include "VectorTypes.h"
|
|
5 #include "Indoor.h"
|
|
6 #include "Render.h"
|
|
7 #include "mm7_data.h"
|
|
8
|
|
9
|
|
10 //----- (004C0262) --------------------------------------------------------
|
|
11 void Viewport::SetScreen( signed int sTL_X, signed int sTL_Y, signed int sBR_X, signed int sBR_Y )
|
|
12 {
|
|
13 unsigned int tl_x; // edx@1
|
|
14 unsigned int br_x; // esi@1
|
|
15 unsigned int tl_y; // edi@3
|
|
16 unsigned int br_y; // eax@3
|
|
17 int v10; // eax@7
|
|
18
|
|
19 tl_x = sTL_X;
|
|
20 br_x = sBR_X;
|
|
21 if ( sTL_X > sBR_X )
|
|
22 {
|
|
23 br_x = sBR_X ^ sTL_X ^ sBR_X; // swap x's
|
|
24 tl_x = br_x ^ sBR_X ^ sTL_X;
|
|
25 }
|
|
26 tl_y = sTL_Y;
|
|
27 br_y = sBR_Y;
|
|
28 if ( (signed int)sTL_Y > (signed int)sBR_Y )
|
|
29 {
|
|
30 br_y = sBR_Y ^ sTL_Y ^ sBR_Y; // swap y's
|
|
31 tl_y = br_y ^ sBR_Y ^ sTL_Y;
|
|
32 }
|
|
33 this->uScreen_TL_X = tl_x;
|
|
34 this->uScreen_TL_Y = tl_y;
|
|
35 this->uScreen_BR_X = br_x;
|
|
36 this->uScreen_BR_Y = br_y;
|
|
37 this->uScreenWidth = br_x - tl_x + 1;
|
|
38 this->uScreenCenterX = (signed int)(br_x + tl_x) >> 1;
|
|
39 if ( pRenderer->pRenderD3D == 0 )
|
|
40 {
|
|
41 this->uScreenHeight = br_y - tl_y + 1;
|
|
42 this->uScreenCenterY = this->uScreen_BR_Y - ((unsigned __int64)(this->field_30 * (signed __int64)(br_y - tl_y + 1)) >> 16);
|
|
43 }
|
|
44 else
|
|
45 {
|
|
46 this->uScreenHeight = br_y - tl_y + 1;
|
|
47 this->uScreenCenterY = (signed int)(br_y + tl_y) >> 1;
|
|
48 }
|
|
49 SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
|
|
50 }
|
|
51
|
|
52 //----- (004C02F8) --------------------------------------------------------
|
|
53 void Viewport::_4C02F8(int a2)
|
|
54 {
|
|
55 this->field_30 = a2;
|
|
56 SetScreen(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y);
|
|
57 }
|
|
58
|
|
59 //----- (004C0312) --------------------------------------------------------
|
|
60 void Viewport::SetViewport( signed int uX, signed int uY, signed int uZ, signed int uW )
|
|
61 {
|
|
62 unsigned int x; // ebx@1
|
|
63 unsigned int y; // edi@3
|
|
64 unsigned int z; // edx@5
|
|
65 unsigned int w; // eax@7
|
|
66
|
|
67 x = uX;
|
|
68 if ( uX < this->uScreen_TL_X )
|
|
69 x = this->uScreen_TL_X;
|
|
70 y = uY;
|
|
71 if ( uY < this->uScreen_TL_Y )
|
|
72 y = this->uScreen_TL_Y;
|
|
73 z = uZ;
|
|
74 if ( uZ > this->uScreen_BR_X )
|
|
75 z = this->uScreen_BR_X;
|
|
76 w = uW;
|
|
77 if ( uW > this->uScreen_BR_Y )
|
|
78 w = this->uScreen_BR_Y;
|
|
79 this->uViewportY = y;
|
|
80 this->uViewportX = x;
|
|
81 this->uViewportZ = z;
|
|
82 this->uViewportW = w;
|
|
83 }
|
|
84
|
|
85 //----- (00443219) --------------------------------------------------------
|
|
86 void ViewingParams::_443219()
|
|
87 {
|
|
88 this->sPartyPosZ += 512;
|
|
89 _4432E7();
|
|
90 }
|
|
91
|
|
92 //----- (00443225) --------------------------------------------------------
|
|
93 void ViewingParams::_443225()
|
|
94 {
|
|
95 this->sPartyPosX -= 512;
|
|
96 _4432E7();
|
|
97 }
|
|
98
|
|
99 //----- (00443231) --------------------------------------------------------
|
|
100 void ViewingParams::_443231()
|
|
101 {
|
|
102 this->sPartyPosZ -= 512;
|
|
103 _4432E7();
|
|
104 }
|
|
105
|
|
106 //----- (0044323D) --------------------------------------------------------
|
|
107 void ViewingParams::_44323D()
|
|
108 {
|
|
109 this->sPartyPosX += 512;
|
|
110 _4432E7();
|
|
111 }
|
|
112
|
|
113 //----- (00443249) --------------------------------------------------------
|
|
114 void ViewingParams::_443249()
|
|
115 {
|
|
116 int v1; // edx@1
|
|
117
|
|
118 v1 = (unsigned __int64)((signed __int64)this->field_2C << 15) >> 16;
|
|
119 this->field_2C = v1;
|
|
120 if ( v1 < 384 )
|
|
121 this->field_2C = 384;
|
|
122 this->sPartyPosX = pParty->vPosition.x;
|
|
123 this->sPartyPosZ = pParty->vPosition.y;
|
|
124 _4432E7();
|
|
125 }
|
|
126
|
|
127 //----- (00443291) --------------------------------------------------------
|
|
128 void ViewingParams::_443291()
|
|
129 {
|
|
130 int v1; // edx@1
|
|
131 int v2; // eax@1
|
|
132
|
|
133 v1 = 2 * this->field_2C;
|
|
134 v2 = 1536;
|
|
135 this->field_2C = v1;
|
|
136 if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor )
|
|
137 v2 = 3072;
|
|
138 if ( v1 > v2 )
|
|
139 this->field_2C = v2;
|
|
140 this->sPartyPosX = pParty->vPosition.x;
|
|
141 this->sPartyPosZ = pParty->vPosition.y;
|
|
142 _4432E7();
|
|
143 }
|
|
144
|
|
145 //----- (004432E7) --------------------------------------------------------
|
|
146 void ViewingParams::_4432E7()
|
|
147 {
|
|
148 ViewingParams *v1; // esi@1
|
|
149 int v2; // ebx@1
|
|
150 signed int v3; // edx@1
|
|
151 int v4; // ecx@1
|
|
152 int v5; // edi@3
|
|
153 int v6; // eax@3
|
|
154 int v7; // eax@5
|
|
155 int result; // eax@7
|
|
156
|
|
157 v1 = this;
|
|
158 v2 = this->field_3A;
|
|
159 v3 = 88 >> this->field_2C / 384;
|
|
160 v4 = (44 - v3) << 9;
|
|
161 if ( v1->sPartyPosZ > v2 + v4 )
|
|
162 v1->sPartyPosZ = v2 + v4;
|
|
163
|
|
164 v5 = v1->field_38;
|
|
165 v6 = (v3 - 44) << 9;
|
|
166 if ( v1->sPartyPosX < v5 + v6 )
|
|
167 v1->sPartyPosX = v5 + v6;
|
|
168
|
|
169 v7 = v2 + v6;
|
|
170 if ( v1->sPartyPosZ < v7 )
|
|
171 v1->sPartyPosZ = v7;
|
|
172
|
|
173 result = v5 + v4;
|
|
174 if ( v1->sPartyPosX > v5 + v4 )
|
|
175 v1->sPartyPosX = result;
|
|
176 }
|
|
177
|
|
178 //----- (00443343) --------------------------------------------------------
|
|
179 void ViewingParams::InitGrayPalette()
|
|
180 {
|
|
181 for (unsigned short i=0; i<256; ++i)
|
|
182 pPalette[i]=GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(i, i, i);
|
|
183 }
|
|
184
|
|
185 //----- (00443365) --------------------------------------------------------
|
|
186 void ViewingParams::_443365()
|
|
187 {
|
|
188 ViewingParams *v1; // esi@1
|
|
189 __int16 *v2; // edi@3
|
|
190 Vec3_short_ *v3; // eax@4
|
|
191 unsigned int v4; // edx@4
|
|
192 signed int v5; // eax@8
|
|
193 Vec3_short_ *v6; // eax@12
|
|
194 signed int v7; // edi@12
|
|
195 signed int v8; // eax@16
|
|
196 char v9; // zf@20
|
|
197 int result; // eax@21
|
|
198 unsigned int v11; // [sp+4h] [bp-1Ch]@3
|
|
199 unsigned int *v12; // [sp+8h] [bp-18h]@3
|
|
200 unsigned int v13; // [sp+Ch] [bp-14h]@8
|
|
201 unsigned int v14; // [sp+10h] [bp-10h]@2
|
|
202 unsigned int v15; // [sp+14h] [bp-Ch]@2
|
|
203 unsigned int v16; // [sp+18h] [bp-8h]@2
|
|
204 unsigned int v17; // [sp+1Ch] [bp-4h]@2
|
|
205
|
|
206 v1 = this;
|
|
207 InitGrayPalette();
|
|
208 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
|
|
209 {
|
|
210 v16 = 0x40000000u;
|
|
211 v14 = 0x40000000u;
|
|
212 v17 = 0xC0000000u;
|
|
213 v15 = 0xC0000000u;
|
|
214 if ( (signed int)pIndoor->pMapOutlines->uNumOutlines > 0 )
|
|
215 {
|
|
216 v2 = (__int16 *)(pIndoor->pMapOutlines->pOutlines);
|
|
217 v11 = pIndoor->pMapOutlines->uNumOutlines;
|
|
218 v12 = (uint *)pIndoor->pMapOutlines->pOutlines;
|
|
219 do
|
|
220 {
|
|
221 v3 = &pIndoor->pVertices[*v2];
|
|
222 v4 = v3->x;
|
|
223 if ( (signed int)v4 < (signed int)v16 )
|
|
224 v16 = v3->x;
|
|
225 if ( (signed int)v4 > (signed int)v17 )
|
|
226 v17 = v3->x;
|
|
227 v5 = v3->y;
|
|
228 v13 = v5;
|
|
229 if ( v5 < (signed int)v14 )
|
|
230 v14 = v4;
|
|
231 if ( v5 > (signed int)v15 )
|
|
232 v15 = v4;
|
|
233 v6 = &pIndoor->pVertices[v2[1]];
|
|
234 v7 = v6->x;
|
|
235 if ( v7 < (signed int)v16 )
|
|
236 v16 = v4;
|
|
237 if ( v7 > (signed int)v17 )
|
|
238 v17 = v4;
|
|
239 v8 = v6->y;
|
|
240 if ( v8 < (signed int)v14 )
|
|
241 v14 = v13;
|
|
242 if ( v8 > (signed int)v15 )
|
|
243 v15 = v13;
|
|
244 v2 = (__int16 *)(v12 + 3);
|
|
245 v9 = v11-- == 1;
|
|
246 v12 += 3;
|
|
247 }
|
|
248 while ( !v9 );
|
|
249 }
|
|
250 v1->uMinimapZoom = 1024;
|
|
251 v1->field_38 = (signed int)(v16 + v17) / 2;
|
|
252 v1->field_28 = 10;
|
|
253 result = (signed int)(v14 + v15) / 2;
|
|
254 v1->field_3A = result;
|
|
255 }
|
|
256 else
|
|
257 {
|
|
258 v1->field_38 = 0;
|
|
259 v1->field_3A = 0;
|
|
260 v1->uMinimapZoom = dword_576E2C;
|
|
261 v1->field_28 = dword_576E28;
|
|
262 }
|
|
263 v1->field_2C = 384;
|
|
264 } |