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