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