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