comparison UI/Books/UIMapBook.cpp @ 1312:ae435824ac4d

books code splitted to separate files
author Gloval
date Wed, 26 Jun 2013 00:22:57 +0400
parents
children 28f87f5234a1
comparison
equal deleted inserted replaced
1311:1dee26137a92 1312:ae435824ac4d
1 #ifdef _MSC_VER
2 #define _CRT_SECURE_NO_WARNINGS
3 #endif
4
5 #include <assert.h>
6
7 #include "..\..\MM7.h"
8 #include "..\..\Render.h"
9 #include "..\..\Mouse.h"
10 #include "..\UIBooks.h"
11 #include "..\..\MapInfo.h"
12 #include "..\..\GUIWindow.h"
13 #include "..\..\GUIFont.h"
14 #include "..\..\Party.h"
15 #include "..\..\AudioPlayer.h"
16 #include "..\..\Outdoor.h"
17 #include "..\..\LOD.h"
18 #include "..\..\Allocator.h"
19 #include "..\..\Viewport.h"
20 #include "..\..\Math.h"
21 #include "..\..\texts.h"
22 //
23 #include "..\..\mm7_data.h"
24
25 //__int16 word_4E1D3A[777]; // weak
26 std::array<__int16, 6> pTownPortalBook_xs = {{260, 324, 147, 385, 390, 19}};
27 std::array<__int16, 6> pTownPortalBook_ys = {{206, 84, 182, 239, 17, 283}};
28 std::array<__int16, 6> pTownPortalBook_ws = {{ 80, 66, 68, 72, 67, 74}};
29 std::array<__int16, 6> pTownPortalBook_hs = {{ 55, 56, 65, 67, 67, 59}};
30
31
32 std::array<unsigned int, 5> pLloydsBeaconsPreviewXs = {{61, 281, 61, 281, 171}}; // 004E249C
33 std::array<unsigned int, 5> pLloydsBeaconsPreviewYs = {{84, 84, 228, 228, 155}};
34 std::array<unsigned int, 5> pLloydsBeacons_SomeXs = {{59, 279, 59, 279, 169}};
35 std::array<unsigned int, 5> pLloydsBeacons_SomeYs = {{82, 82, 226, 226, 153}};
36
37
38
39
40
41
42 //----- (00411150) --------------------------------------------------------
43 void BookUI_DrawTownPortalMap()
44 {
45 //signed int v0; // edi@1
46 //__int16 v1; // dx@8
47 //POINT *v2; // edi@17
48 int v3; // edi@17
49 //__int16 v4; // dx@24
50 GUIWindow v6; // [sp+Ch] [bp-64h]@1
51 //POINT v7; // [sp+60h] [bp-10h]@17
52 POINT a2; // [sp+68h] [bp-8h]@17
53
54 pRenderer->ClearZBuffer(0, 479);
55 pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook);
56 pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
57
58 v6.uFrameX = game_viewport_x;
59 v6.uFrameY = game_viewport_y;
60 v6.uFrameWidth = game_viewport_width;
61 v6.uFrameHeight = game_viewport_height;
62 v6.uFrameZ = game_viewport_z;
63 v6.uFrameW = game_viewport_w;
64
65 const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE,
66 PARTY_QUEST_FOUNTAIN_PIERPONT,
67 PARTY_QUEST_FOUNTAIN_NIGHON,
68 PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE,
69 PARTY_QUEST_FOUNTAIN_CELESTIA,
70 PARTY_QUEST_FOUNTAIN_THE_PIT};
71 for (uint i = 0; i < 6; ++i)
72 {
73
74 if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i]))
75 pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i],
76 pTownPortalBook_ys[i],
77 pTexture_TownPortalIcons[i], i + 1);
78 }
79
80 /* v0 = 0;
81 do
82 {
83 if ( !v0 )
84 {
85 v1 = 206;
86 LABEL_14:
87 if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v1) )
88 goto LABEL_16;
89 goto LABEL_15;
90 }
91 if ( v0 == 1 )
92 {
93 v1 = 208;
94 goto LABEL_14;
95 }
96 if ( v0 == 2 )
97 {
98 v1 = 207;
99 goto LABEL_14;
100 }
101 if ( v0 == 3 )
102 {
103 v1 = 211;
104 goto LABEL_14;
105 }
106 if ( v0 == 4 )
107 {
108 v1 = 209;
109 goto LABEL_14;
110 }
111 if ( v0 == 5 )
112 {
113 v1 = 210;
114 goto LABEL_14;
115 }
116 LABEL_15:
117 pRenderer->DrawMaskToZBuffer(
118 pTownPortalBook_xs[v0],
119 pTownPortalBook_ys[v0],
120 *(&pTexture_TownPortalHarmn + v0),
121 v0 + 1);
122 LABEL_16:
123 ++v0;
124 }
125 while ( v0 < 6 );*/
126
127 pMouse->GetCursorPos(&a2);
128 //v2 = pMouse->GetCursorPos(&a2);
129 v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF;
130
131 if (v3)
132 {
133 if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1]))
134 pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]);
135 }
136 v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);
137
138
139 /* if ( !v3 ) // Town Portal
140 {
141 v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); // "Town Portal"
142 return;
143 }
144 if ( v3 == 1 )
145 {
146 v4 = 206;
147 LABEL_30:
148 if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) )
149 goto LABEL_31;
150 v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); // "Town Portal"
151 return;
152 }
153 if ( v3 == 2 )
154 {
155 v4 = 208;
156 goto LABEL_30;
157 }
158 if ( v3 == 3 )
159 {
160 v4 = 207;
161 goto LABEL_30;
162 }
163 if ( v3 == 4 )
164 {
165 v4 = 211;
166 goto LABEL_30;
167 }
168 if ( v3 == 5 )
169 {
170 v4 = 209;
171 goto LABEL_30;
172 }
173 if ( v3 == 6 )
174 {
175 v4 = 210;
176 goto LABEL_30;
177 }
178 LABEL_31:
179 pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3));
180 v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/
181 }
182 // 4E1D3A: using guessed type __int16 word_4E1D3A[];
183
184 //----- (00410DEC) --------------------------------------------------------
185 unsigned int __cdecl DrawLloydBeaconsScreen()
186 {
187 Player *pPlayer; // esi@1
188 char *v1; // eax@1
189 unsigned __int16 v2; // ax@6
190 unsigned int result; // eax@11
191 unsigned int v4; // esi@13
192 unsigned int v5; // ecx@13
193 char v6; // zf@13
194 LloydBeacon *v7; // esi@14
195 int v8; // eax@14
196 unsigned __int64 v9; // kr08_8@14
197 unsigned int v10; // esi@14
198 unsigned int v11; // eax@14
199 char *v12; // eax@19
200 char *v13; // ecx@22
201 int v14; // eax@27
202 Texture *v19; // [sp-4h] [bp-8Ch]@4
203 GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1
204 unsigned int v23; // [sp+64h] [bp-24h]@14
205 __int64 v24; // [sp+68h] [bp-20h]@14
206 unsigned int v25; // [sp+70h] [bp-18h]@13
207 char *Str; // [sp+74h] [bp-14h]@14
208 int v27; // [sp+78h] [bp-10h]@11
209 LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12
210 RGBTexture *v29; // [sp+80h] [bp-8h]@12
211 int uNumMaxBeacons; // [sp+84h] [bp-4h]@6
212
213 pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid];
214 pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]);
215 v1 = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon
216 pWindow.uFrameX = game_viewport_x;
217 pWindow.uFrameY = game_viewport_y;
218 pWindow.uFrameWidth = 428;
219 pWindow.uFrameHeight = game_viewport_height;
220 pWindow.uFrameZ = 435;
221 pWindow.uFrameW = game_viewport_w;
222 if ( !bRecallingBeacon )
223 v1 = pGlobalTXT_LocalizationStrings[375]; // Set Beacon
224 sprintf(pTmpBuf.data(), "%s", v1);
225 pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u);
226 if ( bRecallingBeacon )
227 {
228 pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on);
229 v19 = pTex_tab_an_6a__zoom_off;
230 }
231 else
232 {
233 pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off);
234 v19 = pTex_tab_an_6b__zoom_on;
235 }
236 pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19);
237 v2 = pPlayer->pActiveSkills[14];
238 uNumMaxBeacons = 1;
239 if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 )
240 {
241 uNumMaxBeacons = 5;
242 }
243 else
244 {
245 if ( v2 & 0x40 )
246 uNumMaxBeacons = 3;
247 }
248 result = 0;
249 v27 = 0;
250 if ( uNumMaxBeacons > 0 )
251 {
252 v29 = pSavegameThumbnails.data();
253 v28 = pPlayer->pInstalledBeacons;
254 while ( 1 )
255 {
256 pWindow.uFrameWidth = 92;
257 v4 = result;
258 pWindow.uFrameHeight = 68;
259 v5 = pLloydsBeaconsPreviewXs[result];
260 pWindow.uFrameY = pLloydsBeaconsPreviewYs[result];
261 v25 = pWindow.uFrameY;
262 pWindow.uFrameX = v5;
263 pWindow.uFrameW = pWindow.uFrameY + 67;
264 v6 = v29->pPixels == 0;
265 pWindow.uFrameZ = v5 + 91;
266 if ( !v6 )
267 break;
268 if ( !bRecallingBeacon )
269 {
270 pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
271 v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0);
272 pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);
273 }
274 LABEL_29:
275 ++v29;
276 ++v28;
277 result = v27++ + 1;
278 if ( v27 >= uNumMaxBeacons )
279 goto LABEL_30;
280 }
281 pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook);
282 pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29);
283 v7 = v28;
284 Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName;
285 v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0);
286 pWindow.uFrameY += -6 - v8;
287 pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u);
288 v9 = v7->uBeaconTime - pParty->uTimePlayed;
289 LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed);
290 HIDWORD(v24) = HIDWORD(v9);
291 v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32;
292 v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60;
293 v11 = v10 / 0x18;
294 if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 )
295 {
296 v13 = pGlobalTXT_LocalizationStrings[57]; // Days
297 if ( v11 > 1 )
298 {
299 sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
300 pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
301 pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
302 goto LABEL_29;
303 }
304 }
305 else
306 {
307 if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 )
308 {
309 if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 )
310 v12 = pGlobalTXT_LocalizationStrings[109];// Hour
311 else
312 v12 = pGlobalTXT_LocalizationStrings[110];// Hours
313 sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12);
314 pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
315 pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
316 goto LABEL_29;
317 }
318 }
319 v13 = pGlobalTXT_LocalizationStrings[56]; // Day
320 sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13);
321 pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4;
322 pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3);
323 goto LABEL_29;
324 }
325 LABEL_30:
326 if ( byte_506360 )
327 {
328 /*result = pMessageQueue_50CBD0->uNumMessages;
329 if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
330 {
331 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon;
332 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
333 result = 3 * pMessageQueue_50CBD0->uNumMessages + 3;
334 *(&pMessageQueue_50CBD0->uNumMessages + result) = 0;
335 ++pMessageQueue_50CBD0->uNumMessages;
336 }*/
337 pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0);
338 }
339 return result;
340 }
341
342
343 //----- (00413980) --------------------------------------------------------
344 void BookUI_Map_Draw()
345 {
346 int v6; // eax@31
347 unsigned int map_id; // eax@35
348 Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3
349 char party_coord[120]; // [sp+Ch] [bp-CCh]@37
350 GUIWindow map_window; // [sp+84h] [bp-54h]@35
351 unsigned int textrX, textrY;
352
353 pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12);
354 if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 )
355 {
356 buttnTxtr = pTex_tab_an_6a__zoom_off;
357 textrY = pViewport->uViewportTL_Y + 2;
358 textrX = pViewport->uViewportTL_X + 408;
359 }
360 else
361 {
362 buttnTxtr = pTex_tab_an_6b__zoom_on;
363 textrY = pViewport->uViewportTL_Y + 1;
364 textrX = pViewport->uViewportTL_X + 398;
365 }
366 pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
367 if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 )
368 {
369 buttnTxtr = pTex_tab_an_7a__zoot_off;
370 textrY = pViewport->uViewportTL_Y + 38;
371 textrX = pViewport->uViewportTL_X + 408;
372 }
373 else
374 {
375 buttnTxtr = pTex_tab_an_7b__zoot_on;
376 textrY = pViewport->uViewportTL_Y + 38;
377 textrX = pViewport->uViewportTL_X + 398;
378 }
379 pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
380 if ( Book_PageBtn3_flag )
381 {
382 buttnTxtr = pTexture_506390;
383 textrY = pViewport->uViewportTL_Y + 113;
384 textrX = pViewport->uViewportTL_X + 408;
385 }
386 else
387 {
388 buttnTxtr = pTexture_506394;
389 textrY = pViewport->uViewportTL_Y + 113;
390 textrX = pViewport->uViewportTL_X + 398;
391 }
392 pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
393 if ( Book_PageBtn4_flag )
394 {
395 buttnTxtr = pTexture_506388;
396 textrY = pViewport->uViewportTL_X + 150;
397 textrX = pViewport->uViewportTL_Y + 408;
398 }
399 else
400 {
401 buttnTxtr = pTexture_50638C;
402 textrY = pViewport->uViewportTL_X + 150;
403 textrX = pViewport->uViewportTL_Y + 399;
404 }
405 pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
406 if ( Book_PageBtn5_flag )
407 {
408 buttnTxtr = pTexture_506380;
409 textrY = pViewport->uViewportTL_Y + 188;
410 textrX = pViewport->uViewportTL_X + 408;
411 }
412 else
413 {
414 buttnTxtr = pTexture_506384;
415 textrY = pViewport->uViewportTL_Y + 188;
416 textrX = pViewport->uViewportTL_X + 397;
417 }
418 pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
419 if ( Book_PageBtn6_flag )
420 {
421 buttnTxtr = pTexture_506378;
422 textrY = pViewport->uViewportTL_Y + 226;
423 textrX = pViewport->uViewportTL_X + 408;
424 }
425 else
426 {
427 buttnTxtr = pTexture_50637C;
428 textrY = pViewport->uViewportTL_Y + 226;
429 textrX = pViewport->uViewportTL_X + 397;
430 }
431 pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr);
432 if ( BtnDown_flag )
433 viewparams->CenterOnParty2();
434 if ( BtnUp_flag )
435 viewparams->CenterOnParty();
436 if ( Book_PageBtn3_flag )
437 viewparams->_443219();
438 if ( Book_PageBtn4_flag )
439 viewparams->_443231();
440 if ( Book_PageBtn5_flag )
441 viewparams->_44323D();
442 if ( Book_PageBtn6_flag )
443 viewparams->_443225();
444
445 if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag )
446 pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
447 BtnUp_flag = 0;
448 BtnDown_flag = 0;
449 Book_PageBtn6_flag = 0;
450 Book_PageBtn5_flag = 0;
451 Book_PageBtn4_flag = 0;
452 Book_PageBtn3_flag = 0;
453 DrawBook_Map_sub(97, 49, 361, 313, 0);
454 pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr);
455 map_window.uFrameWidth = game_viewport_width;
456 map_window.uFrameHeight = game_viewport_height;
457 map_window.uFrameX = game_viewport_x;
458 map_window.uFrameY = game_viewport_y;
459 map_window.uFrameZ = game_viewport_z;
460 map_window.uFrameW = game_viewport_w;
461 map_id = pMapStats->GetMapInfo(pCurrentMapName.data());
462 if ( map_id )
463 map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3);
464
465 map_window.uFrameX = 0;
466 sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d y: %d"
467 map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0);
468 }
469
470 //----- (00442955) --------------------------------------------------------
471 void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 )
472 {
473 int v5; // ebx@1
474 int v6; // edi@1
475 BLVMapOutlines *v7; // eax@8
476 unsigned __int8 v8; // zf@8
477 unsigned __int8 v9; // sf@8
478 int v10; // esi@10
479 unsigned int v11; // edx@11
480 __int16 v12; // cx@12
481 signed int v13; // eax@15
482 int v14; // eax@16
483 Vec3_short_ *v15; // ecx@16
484 int v16; // edx@16
485 int v17; // ecx@16
486 Vec3_short_ *v18; // eax@16
487 int v19; // ecx@16
488 int v20; // eax@16
489 signed int v21; // esi@18
490 int v22; // ecx@21
491 BLVMapOutline *v23; // ecx@21
492 Vec3_short_ *v24; // edx@21
493 Vec3_short_ *v25; // eax@21
494 int v26; // ecx@21
495 unsigned __int16 *v27; // edi@21
496 int v28; // edx@21
497 int v29; // eax@21
498 double v30; // st7@23
499 signed __int64 v31; // qax@23
500 unsigned short *v32; // edx@23
501 int textr_width; // esi@23
502 signed int v34; // eax@23
503 signed int v35; // ecx@23
504 int v36; // esi@27
505 int v37; // ecx@27
506 int v38; // edx@31
507 unsigned int v39; // eax@33
508 short *v40; // esi@33
509 short *v41; // edi@33
510 unsigned __int8 v42; // cf@33
511 unsigned int v43; // ecx@33
512 short *v44; // edi@33
513 short *v45; // esi@33
514 int v46; // ecx@33
515 signed int v47; // esi@38
516 signed int v48; // ecx@38
517 int v49; // eax@38
518 signed int v50; // edx@55
519 unsigned int v51; // ecx@55
520 int result; // eax@72
521 int v53; // eax@75
522 int v54; // esi@75
523 int v55; // eax@75
524 __int16 v56; // si@85
525 double v57; // st7@85
526 int v58; // ebx@85
527 signed __int64 v59; // qax@85
528 signed int v60; // edi@85
529 signed __int64 v61; // qax@85
530 signed int v62; // ebx@85
531 signed int v63; // esi@85
532 int v64; // eax@87
533 unsigned int v65; // ebx@95
534 unsigned short *v66; // edx@95
535 unsigned __int16 *v67; // esi@96
536 int v68; // edi@98
537 unsigned __int16 v69; // cx@99
538 unsigned int v70; // [sp-10h] [bp-48074h]@80
539 unsigned int v71; // [sp-Ch] [bp-48070h]@80
540 unsigned int v72; // [sp-8h] [bp-4806Ch]@80
541 signed int v73; // [sp-4h] [bp-48068h]@59
542 unsigned __int16 v74; // [sp-4h] [bp-48068h]@79
543 unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23
544 int v76; // [sp+4800Ch] [bp-58h]@23
545 unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27
546 unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23
547 unsigned int surfPitch; // [sp+48018h] [bp-4Ch]@1
548
549 int v81; // [sp+48020h] [bp-44h]@23
550 unsigned __int16* render16_data;
551 unsigned char* texture8_data;
552 unsigned char* curr_line;
553 int scale_increment;
554 int scaled_posX;
555 int scaled_posY;
556 int stepX_r;
557 int stepY_r;
558
559
560 unsigned int teal; // [sp+48028h] [bp-3Ch]@8
561 int v84; // [sp+4802Ch] [bp-38h]@1
562 int screenCenter_X; // [sp+48030h] [bp-34h]@1
563 int v86; // [sp+48034h] [bp-30h]@1
564 int v87; // [sp+48038h] [bp-2Ch]@16
565 unsigned int v88; // [sp+4803Ch] [bp-28h]@16
566 int black; // [sp+48040h] [bp-24h]@8
567 int screenCenterY; // [sp+48044h] [bp-20h]@1
568 unsigned int i; // [sp+48048h] [bp-1Ch]@9
569 unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16
570 unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16
571 signed int screenWidth; // [sp+48054h] [bp-10h]@8
572 unsigned int v95; // [sp+48058h] [bp-Ch]@16
573 int v96; // [sp+4805Ch] [bp-8h]@10
574 const void *v97; // [sp+48060h] [bp-4h]@16
575 unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85
576 int a5a; // [sp+48070h] [bp+Ch]@86
577
578 tl_x = tl_x;
579 tl_y = tl_y;
580 screenCenter_X = (signed int)(tl_x + br_x) >> 1;
581 screenCenterY = (signed int)(tl_y + br_y) >> 1;
582 surfPitch = pRenderer->uTargetSurfacePitch;
583 pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y);
584 v5 = viewparams->field_2C;
585 v6 = viewparams->sViewCenterX;
586 v86 = viewparams->sViewCenterX;
587 v84 = viewparams->sViewCenterY;
588 if ( viewparams->field_2C != 384 )
589 {
590 if ( viewparams->field_2C == 768 )
591 {
592 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
593 v5 = 680;
594 }
595 }
596 else
597 {
598 v6 = viewparams->indoor_center_x;
599 v86 = viewparams->indoor_center_x;
600 v84 = viewparams->indoor_center_y;
601 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
602 v5 = viewparams->field_2C - 34;
603 }
604 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor)
605 {
606 screenWidth = br_x - tl_x + 1;
607 screenHeight = br_y - tl_y + 1;
608 render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
609 texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask;
610 pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16;
611 scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5;
612
613 v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2));
614
615
616 teal = (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16;
617 // v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16);
618
619 // v32 = map_texture_16;
620 textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
621 stepY_r = (int)(signed __int64)((double)(- v84 - 22528 / (v5 / 384)+ 32768) / v30) << 16;
622 // v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
623 black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30);
624
625 // v76 = textr_width;
626 scaled_posY = stepY_r >> 16;
627 //nearest neiborhood scaling
628 if ( texture8_data)
629 {
630 for(uint i=0; i<screenHeight;++i)
631 {
632 curr_line=&texture8_data[scaled_posY*textr_width];
633 stepX_r=teal;
634 for(uint j=0; j<screenWidth;++j)
635 {
636 scaled_posX=stepX_r>>16;
637 map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)];
638 stepX_r+=scale_increment;
639 }
640 stepY_r+=scale_increment;
641 scaled_posY=stepY_r>>16;
642 }
643 }
644 //move visible square to render
645 for(uint i=0; i<screenHeight;++i)
646 {
647 if ( screenWidth > 0 )
648 {
649 memcpy((void*)&render16_data[surfPitch*i],(void*)&map_texture_16[i*screenWidth], screenWidth*2);
650 }
651 }
652 }
653 else
654 {
655 black = TargetColor(0, 0, 0);
656 teal = TargetColor(0, 0xFFu, 0xFFu);
657 v7 = pIndoor->pMapOutlines;
658 uNumBlueFacesInBLVMinimap = 0;
659 v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
660 v9 = pIndoor->pMapOutlines->uNumOutlines < 0;
661 screenWidth = 0;
662 if ( !(v9 | v8) )
663 {
664 i = 0;
665 do
666 {
667 v10 = (int)((char *)v7 + i + 4);
668 v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes;
669 if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) ))
670 {
671 v12 = *(short *)((char *)v7 + i + 14);
672 if ( !(v12 & 1) )
673 {
674 if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 ))
675 {
676 v96 = (signed int)screenWidth >> 3;
677 v13 = screenWidth;
678 *(short *)(v10 + 10) = v12 | 1;
679 pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8);
680 }
681 }
682 if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1)
683 {
684 v14 = *(short *)v10;
685 v88 = v5;
686 v15 = &pIndoor->pVertices[v14];
687 v16 = v15->x;
688 v17 = v15->y - v84;
689 v93 = (unsigned __int16 *)(v16 - v6);
690 screenHeight = v17;
691 v18 = &pIndoor->pVertices[*(short *)(v10 + 2)];
692 v19 = v18->x;
693 v20 = v18->y - v84;
694 v95 = v19 - v6;
695 v97 = (const void *)v20;
696 v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16;
697 v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)v5) >> 16;
698 v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16);
699 screenHeight = (unsigned __int64)(v20 * (signed __int64)v5) >> 16;
700 pRenderer->RasterLine2D(
701 screenCenter_X + v88,
702 screenCenterY - v87,
703 screenCenter_X + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16),
704 screenCenterY - screenHeight,
705 black);
706 v7 = pIndoor->pMapOutlines;
707 }
708 }
709 ++screenWidth;
710 i += 12;
711 }
712 while ( screenWidth < (signed int)v7->uNumOutlines );
713 }
714 v21 = 0;
715 if ( (signed int)uNumBlueFacesInBLVMinimap > 0 )
716 {
717 while ( 1 )
718 {
719 v22 = pBlueFacesInBLVMinimapIDs[v21];
720 v87 = v5;
721 v23 = &v7->pOutlines[v22];
722 v24 = &pIndoor->pVertices[v23->uVertex1ID];
723 v25 = &pIndoor->pVertices[v23->uVertex2ID];
724 v26 = v25->x;
725 v27 = (unsigned __int16 *)(v24->x - v86);
726 v28 = v24->y - v84;
727 v29 = v25->y - v84;
728 v93 = v27;
729 screenHeight = v28;
730 v97 = (const void *)v29;
731 v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16;
732 v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16;
733 i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16;
734 v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16;
735 pRenderer->RasterLine2D(
736 screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16),
737 screenCenterY - v88,
738 screenCenter_X + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16),
739 screenCenterY - v95,
740 teal);
741 ++v21;
742 if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap )
743 break;
744 v7 = pIndoor->pMapOutlines;
745 }
746 v6 = v86;
747 }
748 }
749 v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 3;
750 v81 = pParty->vPosition.y - v84;
751 v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16);
752 v48 = 1;
753 v49 = screenCenterY - (int)v97 - 3;
754 if ( v47 >= (signed int)tl_x )
755 {
756 if ( v47 > (signed int)br_x )
757 {
758 if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 6) > (signed int)br_x )
759 v48 = 0;
760 v47 = br_x;
761 }
762 }
763 else
764 {
765 if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X) < (signed int)tl_x )
766 v48 = 0;
767 v47 = tl_x;
768 }
769 if ( v49 >= (signed int)tl_y )
770 {
771 if ( v49 > br_y )
772 {
773 if ( screenCenterY - (signed int)v97 - 6 > br_y )
774 v48 = 0;
775 v49 = br_y;
776 }
777 }
778 else
779 {
780 if ( screenCenterY - (signed int)v97 < (signed int)tl_y )
781 v48 = 0;
782 v49 = tl_y;
783 }
784 if ( v48 == 1 )
785 {
786 v50 = 0;
787 v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask;
788 if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 )
789 {
790 if ( (signed int)v51 > 384 )
791 {
792 if ( (signed int)v51 >= 640 )
793 {
794 if ( (signed int)v51 > 896 )
795 {
796 if ( (signed int)v51 >= 1152 )
797 {
798 if ( (signed int)v51 > 1408 )
799 {
800 if ( (signed int)v51 >= 1664 )
801 {
802 if ( (signed int)v51 <= 1920 )
803 v73 = 7;
804 }
805 else
806 {
807 v73 = 6;
808 }
809 }
810 else
811 {
812 v73 = 5;
813 }
814 }
815 else
816 {
817 v73 = 4;
818 }
819 }
820 else
821 {
822 v73 = 3;
823 }
824 }
825 else
826 {
827 v73 = 2;
828 }
829 if( (signed int)v51 <=1920)
830 v50 = v73;
831 }
832 else
833 v50 = 1;
834 }
835 pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50]));
836 }
837 result = TargetColor(0xFFu, 0xFFu, 0xFFu);
838 v95 = 0;
839 v86 = result;
840 if ( (signed int)uNumLevelDecorations > 0 )
841 {
842 screenWidth = (unsigned int)&pLevelDecorations[0].vPosition;
843 do
844 {
845 if ( *(char *)(screenWidth - 2) & 8 )
846 {
847 v53 = *(int *)(screenWidth + 4) - v84;
848 v93 = (unsigned __int16 *)(*(int *)screenWidth - v6);
849 screenHeight = v53;
850 v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
851 v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16);
852 v55 = screenCenterY - (int)v97;
853 if ( v54 >= pRenderer->raster_clip_x )
854 {
855 if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w )
856 {
857 v74 = v86;
858 if ( v5 > 512 )
859 {
860 v96 = v55 + 1;
861 black = v55 - 1;
862 pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86);
863 pRenderer->RasterLine2D(v54, black, v54, v96, v86);
864 ++v54;
865 v74 = v86;
866 v72 = v96;
867 v71 = v54;
868 v70 = black;
869 }
870 else
871 {
872 v72 = screenCenterY - (int)v97;
873 v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X;
874 v70 = screenCenterY - (int)v97;
875 }
876 pRenderer->RasterLine2D(v54, v70, v71, v72, v74);
877 }
878 }
879 }
880 ++v95;
881 result = v95;
882 screenWidth += 32;
883 }
884 while ( (signed int)v95 < (signed int)uNumLevelDecorations );
885 }
886 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
887 {
888 screenCenterY = br_x - tl_x + 1;
889 v95 = br_y - tl_y + 1;
890 v77 = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch];
891 v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2;
892 black = (1 << (v56 + 16)) / v5;
893 v57 = (double)(1 << (16 - v56));
894 v58 = 22528 / (v5 / 384);
895 v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57);
896 v60 = (int)v59 << 16;
897 v97 = (const void *)((int)v59 << 16);
898 v61 = (signed __int64)((double)(32768 - v58 - v84) / v57);
899 pPalette_16 = (unsigned __int16 *)(v60 >> 16);
900 v62 = (int)v61 << 16;
901 teal = v60 >> 16;
902 v63 = (signed __int16)v61;
903 a4a = map_texture_16;
904 result = TargetColor(0xCu, 0xCu, 0xCu);
905 screenCenter_X = 0;
906 for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X )
907 {
908 a5a = 0;
909 if ( screenCenterY > 0 )
910 {
911 v96 = (v63 - 80) / 4;
912 v64 = teal;
913 do
914 {
915 v81 = (v64 - 80) / 4;
916 if ( !pOutdoor->_47F04C(v81, v96) )
917 {
918 if ( pOutdoor->_47F097(v81, v96) )
919 {
920 if ( !((a5a + screenCenter_X) % 2) )
921 *a4a = i;
922 }
923 else
924 {
925 *a4a = 0;
926 }
927 }
928 ++a4a;
929 v97 = (char *)v97 + black;
930 v64 = (signed int)v97 >> 16;
931 ++a5a;
932 }
933 while ( a5a < screenCenterY );
934 }
935 v62 += black;
936 v97 = (const void *)v60;
937 a4a += screenCenterY - a5a;
938 v63 = v62 >> 16;
939 ++screenCenter_X;
940 teal = (unsigned int)pPalette_16;
941 }
942 v65 = v95;
943 v66 = map_texture_16;
944 if ( (signed int)v95 > 0 )
945 {
946 v67 = v77;
947 result = 2 * (surfPitch - screenCenterY);
948 do
949 {
950 if ( screenCenterY > 0 )
951 {
952 v68 = screenCenterY;
953 do
954 {
955 v69 = *(short *)v66;
956 if ( !*(short *)v66 || v69 == (short)i )
957 *v67 = v69;
958 ++v66;
959 ++v67;
960 --v68;
961 }
962 while ( v68 );
963 }
964 v67 = (unsigned __int16 *)((char *)v67 + result);
965 --v65;
966 }
967 while ( v65 );
968 }
969 }
970 }
971
972