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