comparison Render.cpp @ 1391:cc9a3a24d61d

Moved stru11, stru12 and some SW Rendering stuff to the archives. stru148 -> struct Polygon
author Nomad
date Thu, 18 Jul 2013 14:42:54 +0200
parents 613c77e51e38
children 8ea496564034
comparison
equal deleted inserted replaced
1390:613c77e51e38 1391:cc9a3a24d61d
219 LABEL_9: 219 LABEL_9:
220 LOBYTE(result) = 0; 220 LOBYTE(result) = 0;
221 return result; 221 return result;
222 } 222 }
223 223
224 //----- (00487389) --------------------------------------------------------
225 void Render::ExecOutdoorDrawSW()
226 {
227 unsigned __int16 *v0; // ebx@1
228 unsigned int v1; // esi@1
229 stru148 *v2; // eax@1
230 Span *v3; // edi@6
231 stru148 *v4; // esi@9
232 Texture *v5; // ebp@10
233 int v6; // esi@16
234 unsigned int v7; // edx@16
235 char *v8; // ecx@17
236 unsigned int v9; // edi@22
237 int v10; // eax@26
238 int v11; // eax@27
239 unsigned int v12; // ebp@32
240 Span *v13; // esi@33
241 int v14; // ecx@37
242 int v15; // eax@40
243 Texture *v16; // ebp@51
244 //unsigned int v17; // eax@51
245 int v18; // eax@54
246 char v19; // al@56
247 unsigned int v20; // eax@57
248 int v21; // ecx@57
249 unsigned int v22; // eax@57
250 stru149 *v23; // eax@65
251 int v24; // eax@67
252 ODMFace *v25; // eax@78
253 signed int v26; // edx@79
254 signed int v27; // ecx@79
255 unsigned int v28; // eax@106
256 unsigned int v29; // ebp@117
257 Span *v30; // esi@118
258 unsigned int v31; // ST04_4@124
259 int v33; // [sp+18h] [bp-44h]@80
260 signed int v34; // [sp+1Ch] [bp-40h]@3
261 signed int v35; // [sp+20h] [bp-3Ch]@79
262 Span **v36; // [sp+24h] [bp-38h]@4
263 unsigned int v37; // [sp+28h] [bp-34h]@1
264 unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1
265 int a1a; // [sp+2Ch] [bp-30h]@26
266 unsigned int a1b; // [sp+2Ch] [bp-30h]@116
267 char v41; // [sp+30h] [bp-2Ch]@57
268
269 v0 = pRenderer->pTargetSurface;
270 v1 = pOutdoorCamera->numStru148s;
271 a1 = pRenderer->pTargetSurface;
272 v2 = array_77EC08.data();
273 v37 = pOutdoorCamera->numStru148s;
274 if ( !(pParty->uFlags & 2) )
275 {
276 v1 = uNumElementsIn80AA28;
277 v2 = ptr_80AA28[0];
278 v37 = uNumElementsIn80AA28;
279 }
280 v34 = 0;
281 if ( (signed int)v1 > 0 )
282 {
283 v36 = &v2->prolly_head;
284 do
285 {
286 if ( pParty->uFlags & 2 )
287 v3 = *v36;
288 else
289 v3 = ptr_80AA28[v34]->prolly_head;
290 if ( v3 )
291 {
292 v4 = v3->pParent;
293 if ( v4 )
294 {
295 v5 = v4->pTexture;
296 if ( v5 )
297 {
298 if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X )
299 {
300 LOBYTE(v4->field_32) |= 2u;
301 v14 = *(int *)&v4->flags;
302 if ( v14 & 0x10 && v4->field_59 != 5 )
303 {
304 dword_80AA20 = (v4->terrain_grid_z - 64) << 25;
305 dword_80AA1C = dword_80AA20 + 0x1FF0000;
306 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000;
307 dword_80AA18 = dword_80AA14 - 0x1FF0000;
308 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(
309 v4->terrain_grid_z,
310 v4->terrain_grid_x - 1) >> 9) & 1;
311 if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) )
312 {
313 if ( *(int *)&v4->flags & 2 )
314 {
315 while ( 1 )
316 {
317 if ( pOutdoorCamera->outdoor_no_wavy_water )
318 sr_sub_48408A_prolly_odm_water_no_waves(v3);
319 else
320 sr_sub_485407_prolly_odm_water_wavy(v3);
321 v3->field_E = LOWORD(unnamed_6BE060[1]);
322 if ( v4->prolly_tail == v3 )
323 break;
324 v3 = v3->pNext;
325 }
326 }
327 else
328 {
329 while ( 1 )
330 {
331 v16 = v4->pTexture;
332 v4->pTexture = pBitmaps_LOD->LoadTexturePtr("wtrtyl");
333 if ( pOutdoorCamera->outdoor_no_wavy_water )
334 sr_sub_48408A_prolly_odm_water_no_waves(v3);
335 else
336 sr_sub_485407_prolly_odm_water_wavy(v3);
337 v18 = v4->terrain_grid_z - 64;
338 v4->pTexture = v16;
339 dword_80AA20 = v18 << 25;
340 dword_80AA1C = (v18 << 25) + 0x1FF0000;
341 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000;
342 dword_80AA18 = dword_80AA14 - 0x1FF0000;
343 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(
344 v4->terrain_grid_z,
345 v4->terrain_grid_x - 1) >> 9) & 1;
346 sr_sub_484442(v3);
347 v3->field_E = LOWORD(unnamed_6BE060[1]);
348 if ( v4->prolly_tail == v3 )
349 break;
350 v3 = v3->pNext;
351 }
352 }
353 }
354 else
355 {
356 while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) )
357 {
358 v3->field_E = LOWORD(unnamed_6BE060[1]);
359 if ( v4->prolly_tail == v3 )
360 break;
361 v3 = v3->pNext;
362 }
363 }
364 }
365 else
366 {
367 v19 = v4->field_59;
368 if ( v19 != 5 )
369 {
370 if ( v14 & 2 )
371 {
372 while ( 1 )
373 {
374 v28 = pBitmaps_LOD->LoadTexture("wtrtyla");
375 v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0);
376 if ( !sr_sub_4847EB(v3) )
377 break;
378 v4->pTexture = v5;
379 if ( !sr_sub_484442(v3) )
380 break;
381 v3->field_E = LOWORD(unnamed_6BE060[1]);
382 if ( v4->prolly_tail == v3 )
383 break;
384 v3 = v3->pNext;
385 v5 = v4->pTexture;
386 }
387 }
388 else
389 {
390 if ( v19 == 1 )
391 {
392 dword_80AA20 = (v4->terrain_grid_z - 64) << 25;
393 dword_80AA1C = dword_80AA20 + 33488896;
394 dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000;
395 dword_80AA18 = dword_80AA14 - 33488896;
396 byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(
397 v4->terrain_grid_z,
398 v4->terrain_grid_x - 1) >> 9) & 1;
399 while ( 1 )
400 {
401 if ( !sr_sub_4847EB(v3) )
402 sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0);
403 v3->field_E = LOWORD(unnamed_6BE060[1]);
404 if ( v4->prolly_tail == v3 )
405 break;
406 v3 = v3->pNext;
407 }
408 }
409 }
410 goto LABEL_14;
411 }
412 v4->ptr_38 = (stru149 *)&v41;
413 v4->_479295();
414 v20 = GetTickCount();
415 v21 = *(int *)&v4->flags;
416 v22 = v20 >> 3;
417 if ( BYTE1(v21) & 4 )
418 {
419 v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1;
420 }
421 else
422 {
423 if ( BYTE1(v21) & 8 )
424 v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1;
425 }
426 if ( BYTE1(v21) & 0x10 )
427 {
428 v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1;
429 }
430 else
431 {
432 if ( BYTE1(v21) & 0x20 )
433 v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1;
434 }
435 v23 = v4->ptr_38;
436 v4->field_52 = 32;
437 v4->field_5A = 5;
438 if ( (double)abs(v23->field_C) > 52428.8 )
439 {
440 v4->field_52 = 8;
441 v4->field_5A = 3;
442 }
443 v24 = *(int *)&v4->flags;
444 if ( !(v24 & 0x10000) )
445 {
446 if ( !(v24 & 2) )
447 {
448 v25 = v4->pODMFace;
449 if ( v25->uPolygonType == 1 )
450 {
451 v26 = v25->pTextureUIDs[0];
452 dword_80AA1C = v26;
453 dword_80AA20 = v26;
454 v27 = v25->pTextureVIDs[0];
455 dword_80AA14 = v27;
456 dword_80AA18 = v27;
457 v35 = 1;
458 if ( v25->uNumVertices > 1u )
459 {
460 v33 = (int)&v25->pTextureVIDs[1];
461 do
462 {
463 if ( dword_80AA20 > *(short *)(v33 - 40) )
464 dword_80AA20 = *(short *)(v33 - 40);
465 if ( v26 < *(short *)(v33 - 40) )
466 {
467 v26 = *(short *)(v33 - 40);
468 dword_80AA1C = *(short *)(v33 - 40);
469 }
470 if ( dword_80AA18 > *(short *)v33 )
471 dword_80AA18 = *(short *)v33;
472 if ( v27 < *(short *)v33 )
473 {
474 v27 = *(short *)v33;
475 dword_80AA14 = *(short *)v33;
476 }
477 ++v35;
478 v33 += 2;
479 }
480 while ( v35 < v25->uNumVertices );
481 v0 = a1;
482 }
483 dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16;
484 dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536;
485 dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16;
486 dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536;
487 }
488 while ( 1 )
489 {
490 if ( !sr_sub_482E07(v3, v0) )
491 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0);
492 v3->field_E = LOWORD(unnamed_6BE060[1]);
493 if ( v4->prolly_tail == v3 )
494 break;
495 v3 = v3->pNext;
496 }
497 goto LABEL_14;
498 }
499 while ( 1 )
500 {
501 LABEL_74:
502 if ( !sr_sub_4839BD(v3, v0) )
503 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0);
504 v3->field_E = LOWORD(unnamed_6BE060[1]);
505 if ( v4->prolly_tail == v3 )
506 break;
507 v3 = v3->pNext;
508 }
509 goto LABEL_14;
510 }
511 if ( v24 & 2 )
512 goto LABEL_74;
513 while ( 1 )
514 {
515 if ( !sr_sub_482A94(v3) )
516 sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0);
517 v3->field_E = LOWORD(unnamed_6BE060[1]);
518 if ( v4->prolly_tail == v3 )
519 break;
520 v3 = v3->pNext;
521 }
522 }
523 }
524 else
525 {
526 v3->field_E = LOWORD(unnamed_6BE060[1]);
527 }
528 }
529 }
530 }
531 LABEL_14:
532 ++v34;
533 LOWORD(v2) = v34;
534 v36 += 67;
535 }
536 while ( v34 < (signed int)v37 );
537 }
538 if ( pParty->uFlags & 2 )
539 {
540 v6 = pOutdoorCamera->numStru148s;
541 v7 = 0;
542 uNumElementsIn80AA28 = 0;
543 if ( pOutdoorCamera->numStru148s > 0 )
544 {
545 v8 = (char *)&array_77EC08[0].flags;
546 do
547 {
548 v2 = *(stru148 **)v8;
549 if ( (unsigned int)v2 & 0x20000 )
550 {
551 ++v7;
552 *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF;
553 LOWORD(v2) = (short)v8 - 48;
554 *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48);
555 }
556 v8 += 268;
557 --v6;
558 }
559 while ( v6 );
560 uNumElementsIn80AA28 = v7;
561 }
562 }
563 v9 = pOutdoorCamera->uNumSpans;
564 unnamed_6BE060[0] = pOutdoorCamera->uNumSpans;
565 if (pOutdoorCamera->numStru148s >= 1999)
566 return;
567
568 array_77EC08[1999]._48607B(&stru_8019C8);
569 array_77EC08[1999].ptr_38->sky_48694B();
570
571 if (pOutdoor->uMainTile_BitmapID == -1)
572 {
573 array_77EC08[1999].pTexture = nullptr;
574 return;
575 }
576 else
577 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uMainTile_BitmapID);
578 array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16);
579 if ( array_77EC08[1999].dimming_level > 20 )
580 array_77EC08[1999].dimming_level = 20;
581 v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX);
582 array_77EC08[1999].v_18.y = 0;
583 array_77EC08[1999].v_18.x = v10;
584 array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX);
585 array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16);
586 a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad)
587 / ((double)pOutdoorCamera->int_fov_rad + 8192.0)
588 + (double)pViewport->uScreenCenterY);
589 cos((double)pIndoorCamera->sRotationX * 0.0030664064);
590 sin((double)pIndoorCamera->sRotationX * 0.0030664064);
591 array_77EC08[1999]._48607B(&stru_8019C8);
592 array_77EC08[1999].ptr_38->sky_48694B();
593
594 if (pOutdoor->uSky_TextureID == -1)
595 {
596 array_77EC08[1999].pTexture = nullptr;
597 return;
598 }
599 else
600 array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uSky_TextureID);
601 array_77EC08[1999].dimming_level = 0;
602 v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);
603 array_77EC08[1999].v_18.y = 0;
604 array_77EC08[1999].v_18.x = -v11;
605 array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);
606 LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed);
607 array_77EC08[1999].field_24 = 0x2000000u;
608 array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;
609 array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed;
610 if ( day_attrib & DAY_ATTRIB_FOG
611 && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5)
612 && pParty->uCurrentHour < 0x15
613 || bUnderwater )
614 {
615 v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1);
616 a1b = (unsigned int)v2;
617 if ( (signed int)v9 <= 0 )
618 return;
619 v29 = v9;
620 while ( 1 )
621 {
622 v30 = &pSpans[v29 - 1];
623 v2 = (stru148 *)v30->field_E;
624 if ( v2 != (stru148 *)unnamed_6BE060[1] )
625 {
626 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X);
627 if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X )
628 goto LABEL_124;
629 if ( v30->field_C == pViewport->uViewportTL_X )
630 {
631 v30->field_E = LOWORD(unnamed_6BE060[1]);
632 }
633 else
634 {
635 v30->field_8 = LOWORD(pViewport->uViewportTL_X);
636 v30->field_C -= LOWORD(pViewport->uViewportTL_X);
637 if ( v30->field_C >= 0 )
638 {
639 LABEL_124:
640 v31 = v30->field_C;
641 v30->pParent = &array_77EC08[1999];
642 fill_pixels_fast(
643 a1b,
644 &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A],
645 v31);
646 j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C);
647 goto LABEL_125;
648 }
649 LOWORD(v2) = LOWORD(unnamed_6BE060[1]);
650 v30->field_E = LOWORD(unnamed_6BE060[1]);
651 }
652 }
653 LABEL_125:
654 --v29;
655 --v9;
656 if ( !v9 )
657 return;
658 }
659 }
660 if ( (signed int)v9 > 0 )
661 {
662 v12 = v9;
663 do
664 {
665 v13 = &pSpans[v12 - 1];
666 v2 = (stru148 *)v13->field_E;
667 if ( v2 != (stru148 *)unnamed_6BE060[1] )
668 {
669 LOWORD(v2) = LOWORD(pViewport->uViewportTL_X);
670 if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X )
671 goto LABEL_109;
672 if ( v13->field_C != pViewport->uViewportTL_X )
673 {
674 v13->field_8 = LOWORD(pViewport->uViewportTL_X);
675 v13->field_C -= LOWORD(pViewport->uViewportTL_X);
676 if ( v13->field_C >= 0 )
677 {
678 LABEL_109:
679 if ( pOutdoorCamera->bNoSky )
680 {
681 const_1_0();
682 }
683 else
684 {
685 v13->pParent = &array_77EC08[1999];
686 if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) )
687 j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C);
688 }
689 }
690 LOWORD(v2) = LOWORD(unnamed_6BE060[1]);
691 v13->field_E = LOWORD(unnamed_6BE060[1]);
692 goto LABEL_114;
693 }
694 v13->field_E = LOWORD(unnamed_6BE060[1]);
695 }
696 LABEL_114:
697 --v12;
698 --v9;
699 }
700 while ( v9 );
701 }
702 }
703
704 //----- (00485044) --------------------------------------------------------
705 int Render::DrawSkySW(Span *a1, stru148 *a2, int a3)
706 {
707 stru148 *v3; // esi@1
708 Span *v4; // edi@1
709 float v5; // ST2C_4@1
710 signed int result; // eax@2
711 int v7; // ST40_4@3
712 stru149 *v8; // eax@3
713 int v9; // ebx@3
714 int v10; // ecx@3
715 int v11; // edx@3
716 int v12; // eax@3
717 int v13; // ST28_4@5
718 int v14; // eax@5
719 signed __int64 v15; // qtt@11
720 int v16; // ST28_4@11
721 int v17; // eax@11
722 signed int v18; // ecx@11
723 int v19; // ST40_4@11
724 int v20; // ST3C_4@11
725 int v21; // ST30_4@11
726 void *v22; // eax@11
727 Texture *v23; // esi@11
728 int v24; // ecx@11
729 unsigned int v25; // esi@11
730 int v26; // edi@11
731 unsigned __int16 *v27; // eax@11
732 int *v28; // ebx@12
733 int v29; // edx@13
734 unsigned __int16 v30; // cx@13
735 int v31; // edx@14
736 unsigned __int16 v32; // cx@14
737 unsigned __int8 v33; // sf@15
738 unsigned __int8 v34; // of@15
739 double v35; // [sp+14h] [bp-38h]@1
740 int v36; // [sp+18h] [bp-34h]@3
741 signed int v37; // [sp+18h] [bp-34h]@11
742 int v38; // [sp+1Ch] [bp-30h]@3
743 signed int v39; // [sp+1Ch] [bp-30h]@11
744 int v40; // [sp+20h] [bp-2Ch]@3
745 void *v41; // [sp+20h] [bp-2Ch]@11
746 int v42; // [sp+24h] [bp-28h]@3
747 unsigned __int8 *v43; // [sp+24h] [bp-28h]@11
748 int v44; // [sp+28h] [bp-24h]@11
749 int v45; // [sp+2Ch] [bp-20h]@3
750 signed int v46; // [sp+30h] [bp-1Ch]@3
751 __int16 v47; // [sp+30h] [bp-1Ch]@11
752 signed int v48; // [sp+34h] [bp-18h]@3
753 int v49; // [sp+34h] [bp-18h]@11
754 int v50; // [sp+38h] [bp-14h]@3
755 unsigned __int16 *v51; // [sp+38h] [bp-14h]@11
756 int v52; // [sp+3Ch] [bp-10h]@4
757 int a1a; // [sp+40h] [bp-Ch]@3
758 int v54; // [sp+44h] [bp-8h]@3
759 int v55; // [sp+48h] [bp-4h]@3
760 int v56; // [sp+54h] [bp+8h]@11
761 int *v57; // [sp+54h] [bp+8h]@11
762
763 v3 = a2;
764 v4 = a1;
765 v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5;
766 v35 = v5 + 6.7553994e15;
767 if ( LODWORD(v35) )
768 {
769 v55 = 65536 / SLODWORD(v35);
770 v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A);
771 v8 = v3->ptr_38;
772 v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C;
773 v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18;
774 v38 = pOutdoorCamera->camera_rotation_y_int_sine;
775 HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine;
776 v45 = v4->field_C;
777 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x;
778 v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8);
779 v48 = 0;
780 v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8);
781 v46 = -v3->field_24;
782 v11 = v4->field_A - 1;
783 v54 = v11;
784 v12 = 65536 / SLODWORD(v35) * (a3 - v11);
785 a1a = 65536 / SLODWORD(v35) * (a3 - v11);
786 while ( 1 )
787 {
788 v52 = v9;
789 if ( v9 )
790 {
791 v13 = abs(v46 >> 14);
792 v14 = abs(v9);
793 v11 = v54;
794 v10 = v50;
795 if ( v13 <= v14 )
796 break;
797 v12 = a1a;
798 }
799 if ( v11 <= (signed int)pViewport->uViewportTL_Y )
800 break;
801 v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x;
802 --v54;
803 a1a += v55;
804 v12 = a1a;
805 v11 = v54;
806 v48 = 1;
807 }
808 if ( v48 )
809 v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16)
810 + v3->v_18.x;
811 LODWORD(v15) = v46 << 16;
812 HIDWORD(v15) = v46 >> 16;
813 v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16);
814 v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16);
815 v18 = v15 / v52;
816 v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask;
817 v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3);
818 v56 = v15 / v52;
819 v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3);
820 v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16;
821 v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3;
822 v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3;
823 v22 = sr_sub_47C178(v18, v3, 0, 1);
824 v23 = v3->pTexture;
825 v41 = v22;
826 v47 = 16 - v23->uWidthLn2;
827 v44 = v23->uTextureWidth - 1;
828 v49 = (v23->uTextureHeight << 16) - 65536;
829 v24 = v4->field_8;
830 v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A];
831 v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A];
832 v25 = v19;
833 v26 = v20;
834 v27 = v51;
835 if ( !(v45 & 1) )
836 goto LABEL_15;
837 --v45;
838 v27 = v51 - 1;
839 v28 = v57;
840 ++v57;
841 while ( 1 )
842 {
843 *v28 = -65536;
844 v31 = v44 & (v25 >> 16);
845 v27 += 2;
846 v25 += v39;
847 v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47)));
848 v26 += v37;
849 *(v27 - 1) = v32;
850 LABEL_15:
851 v34 = __OFSUB__(v45, 2);
852 v33 = v45 - 2 < 0;
853 v45 -= 2;
854 if ( v33 ^ v34 )
855 break;
856 v29 = v44 & (v25 >> 16);
857 v25 += v39;
858 v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47)));
859 v26 += v37;
860 v28 = v57;
861 *v27 = v30;
862 v57 += 2;
863 v28[1] = -65536;
864 }
865 result = 1;
866 }
867 else
868 {
869 result = 0;
870 }
871 return result;
872 }
873
874 //----- (0047F5C6) --------------------------------------------------------
875 float Render::DrawBezierTerrain()
876 {
877 //__debugbreak();Ritor1: it's temporarily
878 //return 0;
879
880 unsigned int pDirectionIndicator1; // ebx@1
881 unsigned int pDirectionIndicator2; // edi@1
882 unsigned int v2; // eax@1
883 int v3; // eax@3
884 int v4; // edi@3
885 int v5; // ebx@3
886 int v6; // esi@3
887 unsigned int v7; // eax@3
888 int v8; // eax@4
889 unsigned int v9; // eax@6
890 int v10; // eax@7
891 //int v11; // ebx@9
892 //int v12; // edi@9
893 int v13; // eax@21
894 int v14; // eax@31
895 int v15; // edi@33
896 int v16; // eax@34
897 int v17; // edx@34
898 int v18; // ebx@34
899 int v19; // eax@36
900 int v20; // eax@39
901 int v21; // ecx@43
902 //char v22; // zf@44
903 int v23; // ecx@47
904 //int v24; // edi@52
905 int v25; // eax@54
906 int v26; // ecx@54
907 int v27; // eax@56
908 int v28; // edx@60
909 int v29; // ecx@61
910 int v30; // ecx@64
911 int v31; // ecx@68
912 int v32; // eax@70
913 //int v33; // ecx@71
914 int v34; // eax@73
915 int v35; // ecx@77
916 int v36; // ecx@81
917 int v37; // ecx@86
918 int v38; // eax@88
919 int v39; // ecx@88
920 int v40; // eax@90
921 int v41; // edx@94
922 //int v42; // ecx@95
923 int v43; // ecx@98
924 int v44; // ecx@102
925 int v45; // eax@104
926 int v46; // eax@107
927 int v47; // ecx@111
928 int v48; // ecx@115
929 int v49; // edi@120
930 int v50; // eax@122
931 int v51; // ecx@122
932 int v52; // eax@124
933 int v53; // edx@128
934 int v54; // ecx@129
935 int v55; // ecx@132
936 int v56; // eax@139
937 int v57; // ecx@140
938 int v58; // eax@142
939 int v59; // ecx@146
940 //int v60; // ecx@147
941 int v61; // ecx@150
942 int v62; // ecx@155
943 int v63; // eax@157
944 int v64; // ecx@157
945 int v65; // eax@159
946 int v66; // edx@163
947 int v67; // ecx@164
948 int v68; // ecx@167
949 //int v69; // eax@173
950 int v70; // edi@178
951 //int v71; // eax@178
952 //int v72; // ecx@178
953 //int x; // ebx@180
954 //int v74; // eax@182
955 //int v75; // eax@184
956 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184
957 int uStartZ; // ecx@184
958 int v79; // ebx@185
959 int v127; // esi@185
960 int v86; // edi@196
961 //int v87; // eax@196
962 //int v88; // ecx@196
963 //int v89; // eax@198
964 //int v90; // ecx@200
965 int v92; // ebx@203
966 //int v93; // ST08_4@204
967 int v97; // ST08_4@204
968 float result; // eax@212
969 //struct
970 //{
971 int v106; // [sp+Ch] [bp-68h]@191
972 int v103; // [sp+10h] [bp-64h]@190
973 int v104; // [sp+12h] [bp-62h]@190
974 //} v102;
975 int v105; // [sp+1Ch] [bp-58h]@1
976 int v107; // [sp+20h] [bp-54h]@3
977 int uEndZ; // [sp+24h] [bp-50h]@3
978 int v108; // [sp+28h] [bp-4Ch]@9
979 int v109; // [sp+2Ch] [bp-48h]@9
980 int v110; // [sp+30h] [bp-44h]@9
981 int v111; // [sp+34h] [bp-40h]@3
982 int v112; // [sp+38h] [bp-3Ch]@6
983 IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9
984 int v114; // [sp+40h] [bp-34h]@9
985 int v115; // [sp+44h] [bp-30h]@9
986 int v116; // [sp+48h] [bp-2Ch]@9
987 //int v117; // [sp+4Ch] [bp-28h]@9
988 int v118; // [sp+50h] [bp-24h]@9
989 int v119; // [sp+54h] [bp-20h]@1
990 int v120; // [sp+58h] [bp-1Ch]@1
991 int i; // [sp+5Ch] [bp-18h]@1
992 int v122; // [sp+60h] [bp-14h]@1
993 int v123; // [sp+64h] [bp-10h]@1
994 int v124; // [sp+68h] [bp-Ch]@1
995 int v125; // [sp+6Ch] [bp-8h]@9
996 int v126; // [sp+70h] [bp-4h]@9
997
998 v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2
999 pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536
1000 pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512
1001 v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;//88
1002 v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;// 66
1003 v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X
1004 v119 = pOutdoorCamera->outdoor_grid_band_3 + v123;
1005 v2 = pOutdoorCamera->uCameraFovInDegrees + 15;//90
1006 i = v124 - pOutdoorCamera->outdoor_grid_band_3;
1007 v122 = v123 - pOutdoorCamera->outdoor_grid_band_3;
1008
1009 if ( v2 > 90 )
1010 v2 = 90;
1011 v3 = (v2 << 11) / 720;
1012 v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3);
1013 v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1);
1014
1015 v106 = stru_5C6E00->Cos(v4);
1016 uEndZ = stru_5C6E00->Sin(v4);
1017
1018 v111 = stru_5C6E00->Cos(v5);
1019 v6 = stru_5C6E00->Sin(v5);
1020
1021 v7 = v4 & stru_5C6E00->uPiMask;
1022 if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi )
1023 v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7];
1024 else
1025 v8 = stru_5C6E00->pTanTable[v7];
1026 v112 = abs(v8);
1027
1028 v9 = v5 & stru_5C6E00->uPiMask;
1029 if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi )
1030 v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9];
1031 else
1032 v10 = stru_5C6E00->pTanTable[v9];
1033 v108 = abs(v10);
1034
1035 //v11 = v124;
1036 //v12 = v123;
1037 v114 = 0;
1038 v115 = 0;
1039 pIndoorCameraD3D_4 = 0;
1040 v125 = 0;
1041 v126 = v124;
1042 v118 = v123;
1043
1044 v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1;
1045 v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1;
1046 uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1;
1047 v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1;
1048
1049 uint _i = 1;
1050 uint j = 1;
1051
1052 terrain_76DDC8[0] = -1;
1053 terrain_76DFC8[0] = -1;
1054 terrain_76E1C8[0] = -1;
1055 terrain_76E3C8[0] = -1;
1056
1057 for( uint _i = 1; _i < 128; _i++)
1058 {
1059 if ( v112 >= 0x10000 )
1060 {
1061 int v1, v2;
1062 /*v111 = 4294967296i64 / v112;
1063 v114 += v111;
1064 if ( v114 >= 65536 )
1065 {
1066 v11 += v110;
1067 v114 = (unsigned __int16)v114;
1068 }
1069 v12 += v109;*/
1070 }
1071 else
1072 {
1073 v124 += v110;
1074 v115 += v112;
1075 if ( v112 + v115 >= 65536 )
1076 {
1077 v123 += v109;
1078 v115 = (unsigned __int16)v115;
1079 }
1080 }
1081 if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 )
1082 break;
1083 //v13 = v116++;
1084 terrain_76E3C8[_i] = v124;
1085 terrain_76E1C8[_i] = v123;
1086 }
1087
1088 for( j = 1; j < 128; j++ )
1089 {
1090 if ( v108 >= 65536 )
1091 {
1092 v111 = 4294967296i64 / v108;
1093 v114 += v111;//
1094 if ( v111 + v114 >= 65536 )
1095 {
1096 v126 += uEndZ;
1097 v114 = (unsigned __int16)v114;//
1098 }
1099 v118 += v106;
1100 }
1101 else
1102 {
1103 v125 += v108;
1104 v126 += uEndZ;
1105 if ( v125 >= 65536 )
1106 {
1107 v118 += v106;
1108 v125 = (unsigned __int16)v125;
1109 }
1110 }
1111 //if ( v117 >= 128 )
1112 //break;
1113 if ( v126 < _i )
1114 break;
1115 if ( v126 > v120 )
1116 break;
1117 v14 = v118;
1118 if ( v118 < v122 )
1119 break;
1120 if ( v118 > v119 )
1121 break;
1122 terrain_76DFC8[j] = v126;
1123 terrain_76DDC8[j] = v14;
1124 }
1125 v16 = 0;
1126 v126 = 0;
1127 v17 = j - 1;
1128 v18 = _i - 1;
1129
1130 switch ( v105 )
1131 {
1132 case 0:
1133 case 7:
1134 {
1135 //v116 = terrain_76DFC8[v17];
1136 if ( v120 > terrain_76DFC8[v17] )
1137 {
1138 v125 = v120;
1139 memset32(terrain_76D9C8.data(), v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1));
1140 v19 = v120;
1141 do
1142 terrain_76DBC8[v126++] = v19--;
1143 while ( v19 >= terrain_76DFC8[v17] );
1144 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] )
1145 {
1146 do
1147 v20 = terrain_76DDC8[v17-- -1];
1148 while ( v20 == terrain_76DDC8[v17 -1] );
1149 }
1150 v16 = v126;
1151 --v17;
1152 }
1153 if ( v17 < 0 )
1154 v17 = 0;
1155 v21 = terrain_76DFC8[v17];
1156 while ( 1 )
1157 {
1158 v125 = terrain_76DFC8[v17];
1159 if ( v21 < v124 )
1160 break;
1161 terrain_76DBC8[v16] = v21;
1162 //v22 = terrain_76DDC8[v17] == 65535;
1163 terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1;
1164 if ( terrain_76DDC8[v17] == 65535 )
1165 {
1166 terrain_76D9C8[v16] = v123 + 1;
1167 break;
1168 }
1169 if ( !v17 )
1170 break;
1171 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] )
1172 {
1173 do
1174 v23 = terrain_76DDC8[v17-- -1];
1175 while ( v23 == terrain_76DDC8[v17 -1] );
1176 }
1177 --v17;
1178 v21 = v125 - 1;
1179 ++v16;
1180 }
1181 v16 = 0;
1182 //v24 = terrain_76E3C8[v18];
1183 v126 = 0;
1184 if ( v120 > terrain_76E3C8[v18] )
1185 {
1186 v125 = v120;
1187 memset32(terrain_76D5C8.data(), v122, 4 * (v120 - terrain_76E3C8[v18] + 1));
1188 do
1189 {
1190 v25 = v126;
1191 v26 = v125--;
1192 ++v126;
1193 terrain_76D7C8[v25] = v26;
1194 }
1195 while ( v125 >= terrain_76E3C8[v18] );
1196 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] )
1197 {
1198 do
1199 v27 = terrain_76E1C8[v18-- -1];
1200 while ( v27 == terrain_76E1C8[v18 -1] );
1201 }
1202 v16 = v126;
1203 --v18;
1204 }
1205 if ( v18 < 0 )
1206 v18 = 0;
1207 v28 = terrain_76E3C8[v18];
1208 while ( v28 >= v124 )
1209 {
1210 v29 = terrain_76E1C8[v18];
1211 terrain_76D7C8[v16] = v28;
1212 terrain_76D5C8[v16] = v29;
1213 if ( v29 == 65535 )
1214 {
1215 v31 = v123;
1216 terrain_76D5C8[v16] = v31;
1217 break;
1218 }
1219 if ( !v18 )
1220 break;
1221 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] )
1222 {
1223 do
1224 v30 = terrain_76E1C8[v18-- -1];
1225 while ( v30 == terrain_76E1C8[v18 -1] );
1226 }
1227 --v18;
1228 --v28;
1229 ++v16;
1230 }
1231 break;
1232 }
1233 case 1:
1234 case 2:
1235 {
1236 //v116 = terrain_76DDC8[v17];
1237 if ( v122 < terrain_76DDC8[v17] )
1238 {
1239 v106 = v122;
1240 memset32(terrain_76DBC8.data(), v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1));
1241 for ( v32 = v122; v32 <= terrain_76DDC8[v17]; v32++)
1242 terrain_76D9C8[v126++] = v32;
1243 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
1244 {
1245 do
1246 v34 = terrain_76DBC8[v17-- -1];
1247 while ( v34 == terrain_76DBC8[v17 -1] );
1248 }
1249 v16 = v126;
1250 --v17;
1251 }
1252 if ( v17 < 0 )
1253 v17 = 0;
1254 v35 = terrain_76DDC8[v17];
1255 v125 = terrain_76DDC8[v17];
1256 while ( v35 <= v123 )
1257 {
1258 //v22 = terrain_76DFC8[v17] == 65535;
1259 terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1;
1260 terrain_76D9C8[v16] = v125;
1261 if ( terrain_76DFC8[v17] == 65535 )
1262 {
1263 terrain_76DBC8[v16] = v124 + 1;
1264 break;
1265 }
1266 if ( !v17 )
1267 break;
1268 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
1269 {
1270 do
1271 v36 = terrain_76DBC8[v17-- -1];
1272 while ( v36 == terrain_76DBC8[v17 -1] );
1273 }
1274 --v17;
1275 ++v125;
1276 v35 = v125;
1277 ++v16;
1278 }
1279 v16 = 0;
1280 v126 = 0;
1281 v37 = terrain_76E1C8[v18];
1282 if ( v122 < v37 )
1283 {
1284 v114 = v122;
1285 memset32(terrain_76D7C8.data(), i, 4 * (v37 - v122 + 1));
1286 do
1287 {
1288 v38 = v126;
1289 v39 = v114;
1290 ++v126;
1291 ++v114;
1292 terrain_76D5C8[v38] = v39;
1293 }
1294 while ( v114 <= terrain_76E1C8[v18] );
1295 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] )
1296 {
1297 do
1298 v40 = terrain_76DFC8[v18-- -1];
1299 while ( v40 == terrain_76DFC8[v18 -1] );
1300 }
1301 v16 = v126;
1302 --v18;
1303 }
1304 if ( v18 < 0 )
1305 v18 = 0;
1306 v41 = terrain_76E1C8[v18];
1307 while ( v41 <= v123 )
1308 {
1309 terrain_76D5C8[v16] = v41;
1310 terrain_76D7C8[v16] = terrain_76E3C8[v18];
1311 if ( terrain_76E3C8[v18] == 65535 )
1312 {
1313 terrain_76D7C8[v16] = v124;
1314 break;
1315 }
1316 if ( !v18 )
1317 break;
1318 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] )
1319 {
1320 do
1321 v43 = terrain_76DFC8[v18-- -1];
1322 while ( v43 == terrain_76DFC8[v18 -1] );
1323 }
1324 --v18;
1325 ++v41;
1326 ++v16;
1327 }
1328 break;
1329 }
1330 case 5:
1331 case 6:
1332 {
1333 //v116 = terrain_76DDC8[v17];
1334 if ( v119 > terrain_76DDC8[v17] )
1335 {
1336 v106 = v119;
1337 memset32(terrain_76DBC8.data(), i, 4 * (v119 - terrain_76DDC8[v17] + 1));
1338 for ( v45 = v119; v45 >= terrain_76DDC8[v17]; v45--)
1339 terrain_76D9C8[v126++] = v45;
1340 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
1341 {
1342 do
1343 v46 = terrain_76DBC8[v17-- -1];
1344 while ( v46 == terrain_76DBC8[v17 -1] );
1345 }
1346 v16 = v126;
1347 --v17;
1348 }
1349 if ( v17 < 0 )
1350 v17 = 0;
1351 v47 = terrain_76DDC8[v17];
1352 v125 = terrain_76DDC8[v17];
1353 while ( v47 >= v123 )
1354 {
1355 //v22 = terrain_76DFC8[v17] == 65535;
1356 terrain_76DBC8[v16] = terrain_76DFC8[v17];
1357 terrain_76D9C8[v16] = v125;
1358 if ( terrain_76DFC8[v17] == 65535 )
1359 {
1360 terrain_76DBC8[v16] = v124;
1361 break;
1362 }
1363 if ( !v17 )
1364 break;
1365 if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] )
1366 {
1367 do
1368 v48 = terrain_76DBC8[v17-- -1];
1369 while ( v48 == terrain_76DBC8[v17 -1] );
1370 }
1371 --v17;
1372 --v125;
1373 v47 = v125;
1374 ++v16;
1375 }
1376 v16 = 0;
1377 v49 = terrain_76E1C8[v18];
1378 v126 = 0;
1379 if ( v119 > v49 )
1380 {
1381 v125 = v119;
1382 memset32(terrain_76D7C8.data(), v120 + 1, 4 * (v119 - v49 + 1));
1383 do
1384 {
1385 v50 = v126;
1386 v51 = v125--;
1387 ++v126;
1388 terrain_76D5C8[v50] = v51;
1389 }
1390 while ( v125 >= terrain_76E1C8[v18] );
1391 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] )
1392 {
1393 do
1394 v52 = terrain_76DFC8[v18-- -1];
1395 while ( v52 == terrain_76DFC8[v18 -1] );
1396 }
1397 v16 = v126;
1398 --v18;
1399 }
1400 if ( v18 < 0 )
1401 v18 = 0;
1402 v53 = terrain_76E1C8[v18];
1403 while ( v53 >= v123 )
1404 {
1405 v54 = terrain_76E3C8[v18];
1406 terrain_76D5C8[v16] = v53;
1407 terrain_76D7C8[v16] = v54 + 1;
1408 if ( v54 == 65535 )
1409 {
1410 terrain_76D7C8[v16] = v124 + 1;
1411 break;
1412 }
1413 if ( !v18 )
1414 break;
1415 if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] )
1416 {
1417 do
1418 v55 = terrain_76DFC8[v18-- -1];
1419 while ( v55 == terrain_76DFC8[v18 -1] );
1420 }
1421 --v18;
1422 --v53;
1423 ++v16;
1424 }
1425 break;
1426 }
1427 case 3:
1428 case 4:
1429 {
1430 //v116 = terrain_76DFC8[v17];
1431 if ( i < terrain_76DFC8[v17] )
1432 {
1433 v106 = i;
1434 memset32(terrain_76D9C8.data(), v122, 4 * (terrain_76DFC8[v17] - i + 1));
1435 v56 = i;
1436 do
1437 {
1438 v57 = v126++;
1439 terrain_76DBC8[v57] = v56++;
1440 }
1441 while ( v56 <= terrain_76DFC8[v17] );
1442 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] )
1443 {
1444 do
1445 v58 = terrain_76DDC8[v17-- -1];
1446 while ( v58 == terrain_76DDC8[v17 -1] );
1447 }
1448 v16 = v126;
1449 --v17;
1450 }
1451 if ( v17 < 0 )
1452 v17 = 0;
1453 v59 = terrain_76DFC8[v17];
1454 while ( 1 )
1455 {
1456 v125 = v59;
1457 if ( v59 > v124 )
1458 break;
1459 terrain_76DBC8[v16] = v59;
1460 //v60 = terrain_76DDC8[v17];
1461 terrain_76D9C8[v16] = terrain_76DDC8[v17];
1462 if ( terrain_76DDC8[v17] == 65535 )
1463 {
1464 terrain_76D9C8[v16] = v123;
1465 break;
1466 }
1467 if ( !v17 )
1468 break;
1469 if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] )
1470 {
1471 do
1472 v61 = terrain_76DDC8[v17-- -1];
1473 while ( v61 == terrain_76DDC8[v17 -1] );
1474 }
1475 --v17;
1476 v59 = v125 + 1;
1477 ++v16;
1478 }
1479 v16 = 0;
1480 v126 = 0;
1481 v62 = terrain_76E3C8[v18];
1482 if ( i < v62 )
1483 {
1484 v114 = i;
1485 memset32(terrain_76D5C8.data(), v119 + 1, 4 * (v62 - i + 1));
1486 do
1487 {
1488 v63 = v126;
1489 v64 = v114;
1490 ++v126;
1491 ++v114;
1492 terrain_76D7C8[v63] = v64;
1493 }
1494 while ( v114 <= terrain_76E3C8[v18] );
1495 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] )
1496 {
1497 do
1498 v65 = terrain_76E1C8[v18-- -1];
1499 while ( v65 == terrain_76E1C8[v18 -1] );
1500 }
1501 v16 = v126;
1502 --v18;
1503 }
1504 if ( v18 < 0 )
1505 v18 = 0;
1506 v66 = terrain_76E3C8[v18];
1507 while ( v66 <= v124 )
1508 {
1509 v67 = terrain_76E1C8[v18];
1510 terrain_76D7C8[v16] = v66;
1511 terrain_76D5C8[v16] = v67 + 1;
1512 if ( terrain_76E1C8[v18] == 65535 )
1513 {
1514 v31 = v123 + 1;
1515 terrain_76D5C8[v16] = v31;
1516 break;
1517 }
1518 if ( !v18 )
1519 break;
1520 if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] )
1521 {
1522 do
1523 v68 = terrain_76E1C8[v18-- -1];
1524 while ( v68 == terrain_76E1C8[v18 -1] );
1525 }
1526 --v18;
1527 ++v66;
1528 ++v16;
1529 }
1530 break;
1531 }
1532 default:
1533 break;
1534 }
1535 //v69 = v16 - 1;
1536 ptr_801A08 = pVerticesSR_806210;
1537 ptr_801A04 = pVerticesSR_801A10;
1538 //v126 = v69;
1539
1540 if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//áëîê
1541 {
1542 for ( i = v16 - 1; i >= 1; --i )
1543 {
1544 //v70 = i;
1545 //v71 = terrain_76D7C8[i];//88
1546 //v72 = terrain_76DBC8[i];//0
1547 if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap
1548 {
1549 terrain_76DBC8[i] = terrain_76D7C8[i];
1550 terrain_76D7C8[i] = terrain_76DBC8[i];
1551 }
1552 //x = terrain_76DBC8[i];//0
1553 v111 = 0;
1554 if ( terrain_76DBC8[i] <= 0 )
1555 terrain_76DBC8[i] = -terrain_76DBC8[i];
1556 //v74 = terrain_76D7C8[i];
1557 if ( terrain_76D7C8[i] <= 0 )
1558 terrain_76D7C8[i] = -terrain_76D7C8[i];
1559 uEndZ = terrain_76D7C8[i] + 2;
1560 //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D;
1561 //uEndZ = v75;
1562 //pIndoorCameraD3D_4 = pIndoorCameraD3D_3;
1563 uStartZ = terrain_76DBC8[i] - 2;
1564 if ( terrain_76DBC8[i] - 2 < uEndZ )
1565 {
1566 v127 = 0;
1567 //v79 = (v73 - 66) << 9;
1568 //v116 = v77;
1569 //pHeight = v79;
1570 v111 = uEndZ - uStartZ;
1571 for (int z = uStartZ; z < uEndZ; ++z)
1572 {
1573 ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512;
1574 ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512;
1575 ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]);
1576
1577 ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;
1578 ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512;
1579 ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1);
1580
1581 if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
1582 {
1583 pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1);
1584 pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1);
1585
1586 pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0);
1587 pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0);
1588 }
1589 //v79 += 512;
1590 v127 ++;
1591 //++v116;
1592 //pHeight = v79;
1593 }
1594 //while ( v116 < v107 );
1595 }
1596 v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]);
1597 v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]);
1598 if ( pRenderer->pRenderD3D )//Ritor1: do comment to test
1599 Render::DrawTerrainD3D(v111, 0, v103, v104);
1600 //Render::RenderTerrainD3D();
1601 else
1602 Render::DrawTerrainSW(v111, 0, v103, v104);
1603 }
1604 }
1605 else
1606 {
1607 for ( i = v16 - 1; i >= 1; --i )
1608 {
1609 //v86 = i;
1610 //v87 = terrain_76D5C8[i];
1611 //v88 = terrain_76D9C8[i];
1612 if ( terrain_76D5C8[i] < terrain_76D9C8[i] )
1613 {
1614 terrain_76D9C8[i] = terrain_76D5C8[i];
1615 terrain_76D5C8[i] = terrain_76D9C8[i];
1616 }
1617 //v89 = terrain_76D9C8[i];
1618 v111 = 0;
1619 if ( terrain_76D9C8[i] <= 0 )
1620 terrain_76D9C8[i] = -terrain_76D9C8[i];
1621 //v90 = terrain_76D5C8[i];
1622 if ( terrain_76D5C8[i] <= 0 )
1623 terrain_76D5C8[i] = -terrain_76D5C8[i];
1624 pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D;
1625 v107 = terrain_76D5C8[i] + 2;
1626 if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 )
1627 {
1628 v86 = 0;
1629 //v116 = terrain_76D9C8[i] - 2;
1630 v92 = (66 - terrain_76D9C8[i]) << 9;
1631 //pHeight = (66 - terrain_76D9C8[i]) << 9;
1632 v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2);
1633 //do
1634 for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 )
1635 {
1636 ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9;
1637 ptr_801A08[v86].vWorldPosition.y = v92;
1638 ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116);
1639
1640 ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9;
1641 ptr_801A04[v86].vWorldPosition.y = v92;
1642 ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116);
1643 if ( !byte_4D864C || !(pGame->uFlags & 0x80) )
1644 {
1645 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1);
1646 pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1);
1647 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0);
1648 pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0);
1649 }
1650 v92 -= 512;
1651 v86 += 48;
1652 //++v116;
1653 //pHeight = v92;
1654 }
1655 //while ( v116 < v107 );
1656 }
1657 v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]);
1658 v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]);
1659 if ( pRenderer->pRenderD3D )
1660 Render::DrawTerrainD3D(v111, 1, v103, v104);
1661 else
1662 Render::DrawTerrainSW(v111, 1, v103, v104);
1663 }
1664 }
1665 result = v126;
1666 pOutdoorCamera->field_40 = v126;
1667 return result;
1668 }
1669 // 47FFC4: inconsistent fpu stack
1670 // 4D864C: using guessed type char byte_4D864C;
1671
1672 224
1673 void Render::RenderTerrainD3D() // New function 225 void Render::RenderTerrainD3D() // New function
1674 { 226 {
1675 char result; // al@3 227 char result; // al@3
1676 int v6; // ecx@8 228 int v6; // ecx@8
1677 struct stru148 *pTile; // ebx@8 229 struct Polygon *pTile; // ebx@8
1678 struct stru148 *v16; 230 struct Polygon *v16;
1679 unsigned int v18; // edi@22 231 unsigned int v18; // edi@22
1680 int v35; // edi@63 232 int v35; // edi@63
1681 int v37; // eax@73 233 int v37; // eax@73
1682 int v39; // eax@80 234 int v39; // eax@80
1683 char v40; // [sp-18h] [bp-70h]@2 235 char v40; // [sp-18h] [bp-70h]@2
1729 // 281 //
1730 for (unsigned int z = 0; z < 127; ++z) 282 for (unsigned int z = 0; z < 127; ++z)
1731 { 283 {
1732 for (unsigned int x = 0; x < 127; ++x) 284 for (unsigned int x = 0; x < 127; ++x)
1733 { 285 {
1734 pTile = &array_77EC08[pOutdoorCamera->numStru148s]; 286 pTile = &array_77EC08[pOutdoorCamera->uNumPolygons];
1735 pTile->flags = 0; 287 pTile->flags = 0;
1736 pTile->field_32 = 0; 288 pTile->field_32 = 0;
1737 pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); 289 pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z);
1738 pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID]; 290 pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID];
1739 if (pTile->uTileBitmapID == 0xFFFF) 291 if (pTile->uTileBitmapID == 0xFFFF)
1783 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - 335 (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) -
1784 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); 336 (norm->z * (float)pOutdoor->vSunlight.z / 65536.0));
1785 pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); 337 pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f);
1786 //----------------------------------------------------------------------------------------------- 338 //-----------------------------------------------------------------------------------------------
1787 339
1788 ++pOutdoorCamera->numStru148s; 340 ++pOutdoorCamera->uNumPolygons;
1789 ++pOutdoorCamera->field_44; 341 ++pOutdoorCamera->field_44;
1790 assert(pOutdoorCamera->numStru148s < 20000); 342 assert(pOutdoorCamera->uNumPolygons < 20000);
1791 343
1792 pTile->uBModelID = 0; 344 pTile->uBModelID = 0;
1793 pTile->uBModelFaceID = 0; 345 pTile->uBModelFaceID = 0;
1794 pTile->field_50 = (8 * (0 | (0 << 6))) | 6; 346 pTile->field_50 = (8 * (0 | (0 << 6))) | 6;
1795 for (unsigned int k = 0; k < pTile->uNumVertices; ++k) 347 for (unsigned int k = 0; k < pTile->uNumVertices; ++k)
1824 } 376 }
1825 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû 377 //else //çäåñü óæå ïîãðàíè÷íûå òàéëû âîäû
1826 //pTile->DrawBorderTiles(); 378 //pTile->DrawBorderTiles();
1827 //-------------------------------------------------------------------------------------------------------------------------------- 379 //--------------------------------------------------------------------------------------------------------------------------------
1828 380
1829 --pOutdoorCamera->numStru148s; 381 --pOutdoorCamera->uNumPolygons;
1830 --pOutdoorCamera->field_44; 382 --pOutdoorCamera->field_44;
1831 } 383 }
1832 } 384 }
1833 } 385 }
1834 386
1846 float v11; // eax@6 398 float v11; // eax@6
1847 double v12; // ST5C_8@6 399 double v12; // ST5C_8@6
1848 double v13; // ST2C_8@6 400 double v13; // ST2C_8@6
1849 int v14; // eax@6 401 int v14; // eax@6
1850 double v15; // st7@6 402 double v15; // st7@6
1851 stru148 *pTile; // ebx@12 403 struct Polygon *pTile; // ebx@12
1852 unsigned __int16 v17; // ax@12 404 unsigned __int16 v17; // ax@12
1853 int v18; // eax@13 405 int v18; // eax@13
1854 signed int v22; // eax@13 406 signed int v22; // eax@13
1855 Vec3_float_ *norm; // eax@15 407 Vec3_float_ *norm; // eax@15
1856 //double v24; // st6@17 408 //double v24; // st6@17
1866 int v33; // edi@38 418 int v33; // edi@38
1867 unsigned int v34; // ecx@47 419 unsigned int v34; // ecx@47
1868 char v35; // zf@47 420 char v35; // zf@47
1869 unsigned int v36; // eax@50 421 unsigned int v36; // eax@50
1870 int v37; // eax@54 422 int v37; // eax@54
1871 //stru148 *v38; // ecx@55 423 //Polygon *v38; // ecx@55
1872 unsigned int v39; // eax@59 424 unsigned int v39; // eax@59
1873 stru148 *v40; // ebx@62 425 struct Polygon *v40; // ebx@62
1874 unsigned __int16 pTileBitmapsID; // ax@62 426 unsigned __int16 pTileBitmapsID; // ax@62
1875 int v42; // eax@63 427 int v42; // eax@63
1876 LightmapBuilder *v43; // ecx@63 428 LightmapBuilder *v43; // ecx@63
1877 int v44; // eax@63 429 int v44; // eax@63
1878 int v45; // eax@63 430 int v45; // eax@63
1887 double v54; // st7@84 439 double v54; // st7@84
1888 unsigned int v55; // ecx@98 440 unsigned int v55; // ecx@98
1889 unsigned int v56; // eax@101 441 unsigned int v56; // eax@101
1890 int v57; // eax@105 442 int v57; // eax@105
1891 unsigned int v58; // eax@109 443 unsigned int v58; // eax@109
1892 stru148 *v59; // esi@112 444 struct Polygon *v59; // esi@112
1893 unsigned __int16 v60; // ax@112 445 unsigned __int16 v60; // ax@112
1894 int v61; // eax@113 446 int v61; // eax@113
1895 signed int v62; // eax@113 447 signed int v62; // eax@113
1896 Vec3_float_ *v63; // eax@114 448 Vec3_float_ *v63; // eax@114
1897 double v64; // st6@116 449 double v64; // st6@116
1899 double v66; // st5@120 451 double v66; // st5@120
1900 double v67; // st5@120 452 double v67; // st5@120
1901 double v68; // st5@120 453 double v68; // st5@120
1902 double v69; // st7@133 454 double v69; // st7@133
1903 int v70; // edi@138 455 int v70; // edi@138
1904 stru148 *v71; // esi@147 456 struct Polygon *v71; // esi@147
1905 unsigned int v72; // ecx@147 457 unsigned int v72; // ecx@147
1906 unsigned int v73; // eax@150 458 unsigned int v73; // eax@150
1907 int v74; // eax@154 459 int v74; // eax@154
1908 unsigned int v75; // eax@158 460 unsigned int v75; // eax@158
1909 //unsigned int v76; // [sp-10h] [bp-E0h]@61 461 //unsigned int v76; // [sp-10h] [bp-E0h]@61
2010 WorldPosToGridCellZ(sY); 562 WorldPosToGridCellZ(sY);
2011 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) 563 if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1))
2012 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y 564 if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y
2013 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) 565 || pVertices2->vWorldPosition.y != v101->vWorldPosition.y )
2014 break;*/ 566 break;*/
2015 pTile = &array_77EC08[pOutdoorCamera->numStru148s]; 567 pTile = &array_77EC08[pOutdoorCamera->uNumPolygons];
2016 pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); 568 pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
2017 if ( pTile->uTileBitmapID != -1 ) 569 if ( pTile->uTileBitmapID != -1 )
2018 { 570 {
2019 pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); 571 pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY);
2020 pTile->field_32 = 0; 572 pTile->field_32 = 0;
2029 norm = &pTerrainNormals[v22]; 581 norm = &pTerrainNormals[v22];
2030 thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - 582 thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) -
2031 (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - 583 (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) -
2032 (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; 584 (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0;
2033 //v25 = thisf + 6.7553994e15; 585 //v25 = thisf + 6.7553994e15;
2034 //v27 = pOutdoorCamera->numStru148s > 1999; 586 //v27 = pOutdoorCamera->uNumPolygons > 1999;
2035 //v26 = pOutdoorCamera->numStru148s - 1999 < 0; 587 //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0;
2036 pTile->dimming_level = floorf(thisf + 0.5f); 588 pTile->dimming_level = floorf(thisf + 0.5f);
2037 if ( pOutdoorCamera->numStru148s >= 1999 ) 589 if ( pOutdoorCamera->uNumPolygons >= 1999 )
2038 return; 590 return;
2039 ++pOutdoorCamera->numStru148s; 591 ++pOutdoorCamera->uNumPolygons;
2040 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary 592 //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary
2041 //goto LABEL_126; 593 //goto LABEL_126;
2042 //{ 594 //{
2043 //--pOutdoorCamera->numStru148s; 595 //--pOutdoorCamera->uNumPolygons;
2044 //goto LABEL_162; 596 //goto LABEL_162;
2045 //} 597 //}
2046 memcpy(&array_50AC10[0], v102, 0x30u); 598 memcpy(&array_50AC10[0], v102, 0x30u);
2047 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); 599 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
2048 array_50AC10[0].u = 0.0; 600 array_50AC10[0].u = 0.0;
2143 LABEL_162: 695 LABEL_162:
2144 v4 = v88 + 1; 696 v4 = v88 + 1;
2145 if ( ++v88 >= v84 ) 697 if ( ++v88 >= v84 )
2146 return; 698 return;
2147 } 699 }
2148 /* v40 = &array_77EC08[pOutdoorCamera->numStru148s]; 700 /* v40 = &array_77EC08[pOutdoorCamera->uNumPolygons];
2149 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); 701 v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
2150 if ( v40->uTileBitmapID == -1 ) 702 if ( v40->uTileBitmapID == -1 )
2151 goto LABEL_162; 703 goto LABEL_162;
2152 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); 704 v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY);
2153 BYTE1(v42) |= 0x80u; 705 BYTE1(v42) |= 0x80u;
2171 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; 723 thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0;
2172 v50 = thisg + 6.755399441055744e15; 724 v50 = thisg + 6.755399441055744e15;
2173 v40->dimming_level = LOBYTE(v50); 725 v40->dimming_level = LOBYTE(v50);
2174 if ( LOBYTE(v50) < 0 ) 726 if ( LOBYTE(v50) < 0 )
2175 v40->dimming_level = 0; 727 v40->dimming_level = 0;
2176 if ( pOutdoorCamera->numStru148s >= 1999 ) 728 if ( pOutdoorCamera->uNumPolygons >= 1999 )
2177 return; 729 return;
2178 ++pOutdoorCamera->numStru148s; 730 ++pOutdoorCamera->uNumPolygons;
2179 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary 731 /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary
2180 //goto LABEL_77; 732 //goto LABEL_77;
2181 { 733 {
2182 --pOutdoorCamera->numStru148s; 734 --pOutdoorCamera->uNumPolygons;
2183 goto LABEL_112; 735 goto LABEL_112;
2184 }*/ 736 }*/
2185 /*memcpy(&array_50AC10[0], v102, 0x30u); 737 /*memcpy(&array_50AC10[0], v102, 0x30u);
2186 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); 738 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
2187 array_50AC10[0].u = 0.0; 739 array_50AC10[0].u = 0.0;
2202 stru154::stru154(&static_sub_0048034E_stru_76D590); 754 stru154::stru154(&static_sub_0048034E_stru_76D590);
2203 }*/ 755 }*/
2204 /*if ( !(byte_76D5C0 & 2) ) 756 /*if ( !(byte_76D5C0 & 2) )
2205 { 757 {
2206 byte_76D5C0 |= 2; 758 byte_76D5C0 |= 2;
2207 stru148(stru_76D590); 759 Polygon(stru_76D590);
2208 atexit(loc_48118F); 760 atexit(loc_48118F);
2209 }*/ 761 }*/
2210 /*v96 = pGame->pLightmapBuilder; 762 /*v96 = pGame->pLightmapBuilder;
2211 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); 763 pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0);
2212 pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); 764 pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0);
2215 { 767 {
2216 thisb = pGame->pIndoorCameraD3D; 768 thisb = pGame->pIndoorCameraD3D;
2217 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) 769 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices )
2218 { 770 {
2219 //LABEL_77: 771 //LABEL_77:
2220 --pOutdoorCamera->numStru148s; 772 --pOutdoorCamera->uNumPolygons;
2221 goto LABEL_112; 773 goto LABEL_112;
2222 } 774 }
2223 thisb->ViewTransform(array_50AC10, uNumVertices); 775 thisb->ViewTransform(array_50AC10, uNumVertices);
2224 thisb->Project(array_50AC10, uNumVertices, 0); 776 thisb->Project(array_50AC10, uNumVertices, 0);
2225 } 777 }
2278 v81 = true; 830 v81 = true;
2279 } 831 }
2280 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); 832 pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81);
2281 } 833 }
2282 LABEL_112: 834 LABEL_112:
2283 v59 = &array_77EC08[pOutdoorCamera->numStru148s]; 835 v59 = &array_77EC08[pOutdoorCamera->uNumPolygons];
2284 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; 836 //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons];
2285 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); 837 v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY);
2286 if ( v59->uTileBitmapID == -1 ) 838 if ( v59->uTileBitmapID == -1 )
2287 goto LABEL_162; 839 goto LABEL_162;
2288 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); 840 *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY);
2289 v61 = v93; 841 v61 = v93;
2300 //v99 = v63; 852 //v99 = v63;
2301 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; 853 thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0;
2302 v59->dimming_level = floorf(thish + 0.5f); 854 v59->dimming_level = floorf(thish + 0.5f);
2303 if ( v59->dimming_level < 0 ) 855 if ( v59->dimming_level < 0 )
2304 v59->dimming_level = 0; 856 v59->dimming_level = 0;
2305 if ( pOutdoorCamera->numStru148s >= 1999 ) 857 if ( pOutdoorCamera->uNumPolygons >= 1999 )
2306 return; 858 return;
2307 ++pOutdoorCamera->numStru148s; 859 ++pOutdoorCamera->uNumPolygons;
2308 if ( !sub_481FC9(v101, v102, pVertices2, v59) ) 860 if ( !sub_481FC9(v101, v102, pVertices2, v59) )
2309 { 861 {
2310 //LABEL_126: 862 //LABEL_126:
2311 --pOutdoorCamera->numStru148s; 863 --pOutdoorCamera->uNumPolygons;
2312 goto LABEL_162; 864 goto LABEL_162;
2313 } 865 }
2314 memcpy(&array_50AC10[0], v102, 0x30u); 866 memcpy(&array_50AC10[0], v102, 0x30u);
2315 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); 867 array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097);
2316 array_50AC10[0].u = 0.0; 868 array_50AC10[0].u = 0.0;
2338 { 890 {
2339 thisc = pGame->pIndoorCameraD3D; 891 thisc = pGame->pIndoorCameraD3D;
2340 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) 892 if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 )
2341 //goto LABEL_126; 893 //goto LABEL_126;
2342 { 894 {
2343 --pOutdoorCamera->numStru148s; 895 --pOutdoorCamera->uNumPolygons;
2344 goto LABEL_162; 896 goto LABEL_162;
2345 } 897 }
2346 thisc->ViewTransform(array_50AC10, v100); 898 thisc->ViewTransform(array_50AC10, v100);
2347 thisc->Project(array_50AC10, v100, 0); 899 thisc->Project(array_50AC10, v100, 0);
2348 } 900 }
2396 v78 = pBitmaps_LOD->pHardwareTextures[v75]; 948 v78 = pBitmaps_LOD->pHardwareTextures[v75];
2397 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary 949 v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary
2398 //v77 = (int)v71; 950 //v77 = (int)v71;
2399 //v76 = v71->uNumVertices; 951 //v76 = v71->uNumVertices;
2400 //goto LABEL_161; 952 //goto LABEL_161;
2401 pRenderer->DrawTerrainPolygon(v71->uNumVertices, (stru148 *)v71, v78, 0, v80); 953 pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80);
2402 goto LABEL_162; 954 goto LABEL_162;
2403 } 955 }
2404 v38 = (stru148 *)v71; 956 v38 = (Polygon *)v71;
2405 goto LABEL_56; 957 goto LABEL_56;
2406 } 958 }
2407 v73 = sr_424EE0_MakeFanFromTriangle(v72); 959 v73 = sr_424EE0_MakeFanFromTriangle(v72);
2408 } 960 }
2409 v71->uNumVertices = v73; 961 v71->uNumVertices = v73;
2410 OutdoorCamera::Project(v73); 962 OutdoorCamera::Project(v73);
2411 goto LABEL_154; 963 goto LABEL_154;
2412 } 964 }
2413 }*/ 965 }*/
2414 // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); 966
2415 // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
2416 // 4D864C: using guessed type char byte_4D864C;
2417 // 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag;
2418
2419 //----- (00481212) --------------------------------------------------------
2420 void Render::DrawTerrainSW(int a1, int a2, int a3, int a4)
2421 {
2422 int v3; // esi@1
2423 int v4; // ecx@1
2424 int v5; // ST10_4@1
2425 int v6; // edi@1
2426 int v7; // ebx@2
2427 int v8; // eax@2
2428 int v9; // eax@3
2429 RenderVertexSoft *v10; // edi@3
2430 RenderVertexSoft *v11; // ebx@4
2431 RenderVertexSoft *v12; // ecx@4
2432 float v13; // eax@6
2433 int v14; // eax@6
2434 double v15; // st7@6
2435 double v16; // st7@6
2436 stru148 *v17; // ebx@12
2437 unsigned __int16 v18; // ax@12
2438 int v19; // eax@13
2439 float v20; // ecx@13
2440 stru220 *v21; // eax@13
2441 int v22; // eax@13
2442 signed int v23; // eax@13
2443 Vec3_float_ *v24; // eax@15
2444 double v25; // st7@18
2445 double v26; // st5@24
2446 double v27; // st5@24
2447 double v28; // st5@24
2448 double v29; // st5@24
2449 Game *v30; // eax@25
2450 RenderVertexSoft *v31; // edi@29
2451 double v32; // st7@31
2452 int v33; // esi@35
2453 RenderVertexSoft *v34; // edx@36
2454 RenderVertexSoft *v35; // ecx@36
2455 signed int v36; // eax@39
2456 signed int v37; // esi@40
2457 stru148 *v38; // ebx@43
2458 unsigned __int16 v39; // ax@43
2459 int v40; // eax@44
2460 float v41; // ecx@44
2461 stru220 *v42; // eax@44
2462 int v43; // eax@44
2463 int v44; // eax@44
2464 signed int v45; // eax@44
2465 Vec3_float_ *v46; // eax@46
2466 double v47; // st7@49
2467 double v48; // st5@57
2468 double v49; // st5@57
2469 double v50; // st5@57
2470 Game *v51; // eax@58
2471 RenderVertexSoft *v52; // edi@62
2472 double v53; // st7@63
2473 int v54; // esi@66
2474 signed int v55; // eax@69
2475 signed int v56; // esi@71
2476 unsigned __int16 v57; // ax@75
2477 stru220 *v58; // eax@76
2478 signed int v59; // eax@76
2479 Vec3_float_ *v60; // eax@77
2480 double v61; // st7@80
2481 double v62; // st5@88
2482 double v63; // st5@88
2483 double v64; // st5@88
2484 Game *v65; // eax@89
2485 double v66; // st7@94
2486 RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36
2487 stru148 *v68; // [sp-8h] [bp-C0h]@36
2488 int v69; // [sp-4h] [bp-BCh]@36
2489 float v70; // [sp+Ch] [bp-ACh]@88
2490 double v71; // [sp+10h] [bp-A8h]@6
2491 double v72; // [sp+18h] [bp-A0h]@82
2492 double v73; // [sp+20h] [bp-98h]@6
2493 double v74; // [sp+28h] [bp-90h]@51
2494 double v75; // [sp+30h] [bp-88h]@6
2495 double v76; // [sp+38h] [bp-80h]@20
2496 double v77; // [sp+40h] [bp-78h]@6
2497 float v78; // [sp+48h] [bp-70h]@57
2498 float v79; // [sp+4Ch] [bp-6Ch]@6
2499 float v80; // [sp+50h] [bp-68h]@6
2500 int v81; // [sp+54h] [bp-64h]@1
2501 int v82; // [sp+58h] [bp-60h]@6
2502 int v83; // [sp+5Ch] [bp-5Ch]@82
2503 int v84; // [sp+60h] [bp-58h]@20
2504 int v85; // [sp+64h] [bp-54h]@1
2505 int v86; // [sp+68h] [bp-50h]@1
2506 int v87; // [sp+6Ch] [bp-4Ch]@51
2507 float v88; // [sp+70h] [bp-48h]@51
2508 int v89; // [sp+74h] [bp-44h]@6
2509 int v90; // [sp+78h] [bp-40h]@1
2510 float a3a; // [sp+7Ch] [bp-3Ch]@24
2511 stru220 *v92; // [sp+80h] [bp-38h]@2
2512 float v93; // [sp+84h] [bp-34h]@44
2513 int v94; // [sp+88h] [bp-30h]@6
2514 float v95; // [sp+8Ch] [bp-2Ch]@1
2515 float v96; // [sp+90h] [bp-28h]@1
2516 float v97; // [sp+94h] [bp-24h]@1
2517 int X; // [sp+98h] [bp-20h]@1
2518 float v99; // [sp+9Ch] [bp-1Ch]@6
2519 int v100; // [sp+A0h] [bp-18h]@6
2520 unsigned __int64 v101; // [sp+A4h] [bp-14h]@6
2521 RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6
2522 RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6
2523 RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3
2524 float pNormalc; // [sp+C0h] [bp+8h]@6
2525 float pNormald; // [sp+C0h] [bp+8h]@6
2526 Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17
2527 Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48
2528 Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77
2529
2530 v3 = a1;
2531 //v4 = *(short *)(a3 + 4);
2532 //v5 = *(short *)(a3 + 6);
2533 v85 = a2;
2534 v86 = a3; //v4;
2535 X = abs(a4); //v5
2536 v6 = 0;
2537 v90 = 0;
2538 v81 = v3 - 1;
2539 v95 = (double)pOutdoor->vSunlight.x / 65536.0;
2540 v96 = (double)pOutdoor->vSunlight.y / 65536.0;
2541 v97 = (double)pOutdoor->vSunlight.z / 65536.0;
2542 if ( v3 - 1 > 0 )
2543 {
2544 while ( 1 )
2545 {
2546 v7 = abs(X);
2547 v8 = abs(v86);
2548 --X;
2549 v92 = &stru_76E5C8[(v7 << 7) + v8];
2550 if ( !v92->field_0
2551 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9],
2552 v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]),
2553 ((v103 = &pVerticesSR_801A10[v9 + 1],
2554 v13 = v10->vWorldPosition.x,
2555 v102 = v12,
2556 v80 = v13,
2557 v73 = v13 + 6.7553994e15,
2558 v101 = __PAIR__((unsigned int)v11, LODWORD(v73)),
2559 v79 = v10->vWorldPosition.y,
2560 v75 = v79 + 6.7553994e15,
2561 v100 = LODWORD(v75),
2562 pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5,
2563 v71 = pNormalc + 6.7553994e15,
2564 v89 = LODWORD(v71),
2565 v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)),
2566 v15 = v11->vWorldPosition.y + v10->vWorldPosition.y,
2567 v94 = v14,
2568 pNormald = v15 * 0.5,
2569 v16 = pNormald + 6.7553994e15,
2570 v77 = v16,
2571 v82 = LODWORD(v77),
2572 LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)),
2573 WorldPosToGridCellX(v101),
2574 WorldPosToGridCellZ(v100),
2575 !byte_4D864C)
2576 || !(pGame->uFlags & 0x80))
2577 && !sub_481EFA(v10, v11, v102, v103, 1)) )
2578 goto LABEL_105;
2579 if ( v10->vWorldPosition.z != v11->vWorldPosition.z
2580 || v11->vWorldPosition.z != v103->vWorldPosition.z
2581 || v103->vWorldPosition.z != v102->vWorldPosition.z )
2582 break;
2583 v17 = &array_77EC08[pOutdoorCamera->numStru148s];
2584 v18 = pOutdoor->GetTileTexture(v101, v100);
2585 v17->uTileBitmapID = v18;
2586 if ( v18 != -1 )
2587 {
2588 v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100);
2589 LOWORD(v19) = v19 | 0x8010;
2590 v20 = v99;
2591 *(int *)&v17->flags = v19;
2592 v21 = v92;
2593 v17->field_59 = 1;
2594 v17->terrain_grid_x = LOBYTE(v20);
2595 v17->field_34 = v21->distance;
2596 v22 = v94;
2597 v17->terrain_grid_z = v94;
2598 v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1];
2599 if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) )
2600 v24 = 0;
2601 else
2602 v24 = &pTerrainNormals[v23];
2603 pNormal = v24;
2604 if ( v24 )
2605 {
2606 v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x);
2607 if ( v25 < 0.0 )
2608 v25 = 0.0;
2609 v99 = v25 * 31.0;
2610 v76 = v99 + 6.7553994e15;
2611 v84 = LODWORD(v76);
2612 v17->dimming_level = 31 - LOBYTE(v76);
2613 }
2614 else
2615 {
2616 v17->dimming_level = 0;
2617 }
2618 if ( pOutdoorCamera->numStru148s >= 1999 )
2619 return;
2620 ++pOutdoorCamera->numStru148s;
2621 if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) )
2622 goto LABEL_104;
2623 v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001);
2624 memcpy(array_50AC10, v104, 0x30u);
2625 array_50AC10[0]._rhw = v26;
2626 array_50AC10[0].u = 0.0;
2627 array_50AC10[0].v = 0.0;
2628 v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001;
2629 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1]));
2630 array_50AC10[1]._rhw = 1.0 / v27;
2631 array_50AC10[1].u = 0.0;
2632 array_50AC10[1].v = 1.0;
2633 v28 = v103->vWorldViewPosition.x + 0.0000001;
2634 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2]));
2635 array_50AC10[2]._rhw = 1.0 / v28;
2636 array_50AC10[2].u = 1.0;
2637 array_50AC10[2].v = 1.0;
2638 v29 = v102->vWorldViewPosition.x + 0.0000001;
2639 memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3]));
2640 array_50AC10[3]._rhw = 1.0 / v29;
2641 array_50AC10[3].u = 1.0;
2642 array_50AC10[3].v = 0.0;
2643 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1);
2644 if ( stru_F8AD28.uNumLightsApplied <= 0 )
2645 {
2646 v17->field_108 = 0;
2647 }
2648 else
2649 {
2650 v30 = pGame;
2651 v17->field_108 = 1;
2652 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal);
2653 }
2654 if ( v104->vWorldViewPosition.x < 8.0
2655 || *(float *)(HIDWORD(v101) + 12) < 8.0
2656 || (v31 = v102, v102->vWorldViewPosition.x < 8.0)
2657 || v103->vWorldViewPosition.x < 8.0 )
2658 {
2659 v36 = sr_4250FE(4u);
2660 }
2661 else
2662 {
2663 v32 = (double)pOutdoorCamera->shading_dist_mist;
2664 if ( v32 >= v104->vWorldViewPosition.x
2665 && v32 >= *(float *)(HIDWORD(v101) + 12)
2666 && v32 >= v102->vWorldViewPosition.x
2667 && v32 >= v103->vWorldViewPosition.x )
2668 {
2669 v33 = sr_4254D2(4);
2670 v17->uNumVertices = v33;
2671 if ( !v33 )
2672 goto LABEL_104;
2673 v34 = (RenderVertexSoft *)HIDWORD(v101);
2674 v35 = v104;
2675 v69 = 0;
2676 v68 = v17;
2677 v67 = v31;
2678 goto LABEL_37;
2679 }
2680 v36 = sr_4252E8(4u);
2681 }
2682 v37 = v36;
2683 if ( !v36 )
2684 goto LABEL_104;
2685 LABEL_41:
2686 OutdoorCamera::Project(v37);
2687 LABEL_102:
2688 v33 = sr_4254D2(v37);
2689 v17->uNumVertices = v33;
2690 if ( !v33 )
2691 goto LABEL_104;
2692 v17->_48276F_sr();
2693 goto LABEL_38;
2694 }
2695 LABEL_105:
2696 v6 = v90++ + 1;
2697 if ( v90 >= v81 )
2698 return;
2699 }
2700 v38 = &array_77EC08[pOutdoorCamera->numStru148s];
2701 v39 = pOutdoor->GetTileTexture(v101, v100);
2702 v38->uTileBitmapID = v39;
2703 if ( v39 == -1 )
2704 goto LABEL_105;
2705 v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100);
2706 BYTE1(v40) |= 0x80u;
2707 v41 = v99;
2708 *(int *)&v38->flags = v40;
2709 v42 = v92;
2710 v38->field_59 = 1;
2711 v38->terrain_grid_x = LOBYTE(v41);
2712 v38->field_34 = v42->distance;
2713 v43 = v94;
2714 v38->terrain_grid_z = v94;
2715 v44 = 2 * (LODWORD(v41) + (v43 << 7));
2716 LODWORD(v93) = v44 * 2;
2717 v45 = pTerrainNormalIndices[v44 + 1];
2718 if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) )
2719 v46 = 0;
2720 else
2721 v46 = &pTerrainNormals[v45];
2722 pNormala = v46;
2723 if ( v46 )
2724 {
2725 v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x);
2726 if ( v47 < 0.0 )
2727 v47 = 0.0;
2728 v88 = v47 * 31.0;
2729 v74 = v88 + 6.7553994e15;
2730 v87 = LODWORD(v74);
2731 v38->dimming_level = 31 - LOBYTE(v74);
2732 }
2733 else
2734 {
2735 v38->dimming_level = 0;
2736 }
2737 if ( v38->dimming_level < 0 )
2738 v38->dimming_level = 0;
2739 if ( pOutdoorCamera->numStru148s >= 1999 )
2740 return;
2741 ++pOutdoorCamera->numStru148s;
2742 if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) )
2743 goto LABEL_74;
2744 v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001);
2745 memcpy(array_50AC10, v104, 0x30u);
2746 array_50AC10[0]._rhw = v48;
2747 array_50AC10[0].u = 0.0;
2748 array_50AC10[0].v = 0.0;
2749 v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001;
2750 memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1]));
2751 array_50AC10[1]._rhw = 1.0 / v49;
2752 array_50AC10[1].u = 0.0;
2753 array_50AC10[1].v = 1.0;
2754 v50 = v103->vWorldViewPosition.x + 0.0000001;
2755 memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2]));
2756 array_50AC10[2]._rhw = 1.0 / v50;
2757 array_50AC10[2].u = 1.0;
2758 array_50AC10[2].v = 1.0;
2759 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0);
2760 if ( stru_F8AD28.uNumLightsApplied <= 0 )
2761 {
2762 v38->field_108 = 0;
2763 }
2764 else
2765 {
2766 v51 = pGame;
2767 v38->field_108 = 1;
2768 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala);
2769 }
2770 if ( v104->vWorldViewPosition.x < 8.0
2771 || *(float *)(HIDWORD(v101) + 12) < 8.0
2772 || (v52 = v103, v103->vWorldViewPosition.x < 8.0) )
2773 {
2774 v55 = sr_4250FE(3u);
2775 }
2776 else
2777 {
2778 v53 = (double)pOutdoorCamera->shading_dist_mist;
2779 if ( v53 >= v104->vWorldViewPosition.x
2780 && v53 >= *(float *)(HIDWORD(v101) + 12)
2781 && v53 >= v103->vWorldViewPosition.x )
2782 {
2783 v54 = sr_4254D2(3);
2784 v38->uNumVertices = v54;
2785 if ( v54 )
2786 {
2787 sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0);
2788 LABEL_68:
2789 sr_sub_481DB2(array_508690, v54, v38);
2790 LABEL_75:
2791 v17 = &array_77EC08[pOutdoorCamera->numStru148s];
2792 v57 = pOutdoor->GetTileTexture(v101, v100);
2793 v17->uTileBitmapID = v57;
2794 if ( v57 == -1 )
2795 goto LABEL_105;
2796 *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100);
2797 v58 = v92;
2798 v17->field_59 = 1;
2799 v17->field_34 = v58->distance;
2800 v17->terrain_grid_z = v94;
2801 v17->terrain_grid_x = LOBYTE(v99);
2802 v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices.data() + LODWORD(v93));
2803 if ( v59 > (signed int)(uNumTerrainNormals - 1) )
2804 {
2805 pNormalb = 0;
2806 v60 = 0;
2807 }
2808 else
2809 {
2810 v60 = &pTerrainNormals[v59];
2811 pNormalb = v60;
2812 }
2813 if ( v60 )
2814 {
2815 v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x);
2816 if ( v61 < 0.0 )
2817 v61 = 0.0;
2818 v93 = v61 * 31.0;
2819 v72 = v93 + 6.7553994e15;
2820 v83 = LODWORD(v72);
2821 v17->dimming_level = 31 - LOBYTE(v72);
2822 }
2823 else
2824 {
2825 v17->dimming_level = 0;
2826 }
2827 if ( v17->dimming_level < 0 )
2828 v17->dimming_level = 0;
2829 if ( pOutdoorCamera->numStru148s >= 1999 )
2830 return;
2831 ++pOutdoorCamera->numStru148s;
2832 if ( !sub_481FC9(v102, v104, v103, v17) )
2833 {
2834 LABEL_104:
2835 --pOutdoorCamera->numStru148s;
2836 goto LABEL_105;
2837 }
2838 v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001);
2839 memcpy(array_50AC10, v104, 0x30u);
2840 array_50AC10[0]._rhw = v62;
2841 array_50AC10[0].u = 0.0;
2842 array_50AC10[0].v = 0.0;
2843 v63 = v103->vWorldViewPosition.x + 0.0000001;
2844 memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1]));
2845 array_50AC10[1]._rhw = 1.0 / v63;
2846 array_50AC10[1].u = 1.0;
2847 array_50AC10[1].v = 1.0;
2848 v64 = v102->vWorldViewPosition.x + 0.0000001;
2849 memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2]));
2850 array_50AC10[2]._rhw = 1.0 / v64;
2851 array_50AC10[2].u = 1.0;
2852 array_50AC10[2].v = 0.0;
2853 pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1);
2854 if ( stru_F8AD28.uNumLightsApplied <= 0 )
2855 {
2856 v17->field_108 = 0;
2857 }
2858 else
2859 {
2860 v65 = pGame;
2861 v17->field_108 = 1;
2862 pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb);
2863 }
2864 if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 )
2865 {
2866 v37 = sr_4250FE(3u);
2867 OutdoorCamera::Project(v37);
2868 if ( !v37 )
2869 goto LABEL_104;
2870 goto LABEL_102;
2871 }
2872 v66 = (double)pOutdoorCamera->shading_dist_mist;
2873 if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x )
2874 {
2875 v37 = sr_4252E8(3u);
2876 if ( !v37 )
2877 goto LABEL_105;
2878 goto LABEL_41;
2879 }
2880 v33 = sr_4254D2(3);
2881 v17->uNumVertices = v33;
2882 if ( !v33 )
2883 goto LABEL_104;
2884 v34 = v104;
2885 v35 = v102;
2886 v69 = 0;
2887 v68 = v17;
2888 v67 = v103;
2889 LABEL_37:
2890 sr_sub_4829B9(v35, v34, v67, v68, v69);
2891 LABEL_38:
2892 sr_sub_481DB2(array_508690, v33, v17);
2893 goto LABEL_105;
2894 }
2895 goto LABEL_74;
2896 }
2897 v55 = sr_4252E8(3u);
2898 }
2899 v56 = v55;
2900 if ( v55 )
2901 {
2902 OutdoorCamera::Project(v55);
2903 v54 = sr_4254D2(v56);
2904 v38->uNumVertices = v54;
2905 if ( v54 )
2906 {
2907 v38->_48276F_sr();
2908 goto LABEL_68;
2909 }
2910 }
2911 LABEL_74:
2912 --pOutdoorCamera->numStru148s;
2913 goto LABEL_75;
2914 }
2915 }
2916 967
2917 //----- (0047BACF) -------------------------------------------------------- 968 //----- (0047BACF) --------------------------------------------------------
2918 void Render::TransformBillboardsAndSetPalettesODM() 969 void Render::TransformBillboardsAndSetPalettesODM()
2919 { 970 {
2920 //int v0; // edi@1 971 //int v0; // edi@1
4353 pBitmaps_LOD->_410423_move_textures_to_device(); 2404 pBitmaps_LOD->_410423_move_textures_to_device();
4354 pSprites_LOD->ReleaseLostHardwareSprites(); 2405 pSprites_LOD->ReleaseLostHardwareSprites();
4355 } 2406 }
4356 2407
4357 //----- (004A2050) -------------------------------------------------------- 2408 //----- (004A2050) --------------------------------------------------------
4358 void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) 2409 void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture)
4359 { 2410 {
4360 Render *v5; // edi@1 2411 Render *v5; // edi@1
4361 unsigned int v6; // ebx@1 2412 unsigned int v6; // ebx@1
4362 LightmapBuilder *v7; // esi@3 2413 LightmapBuilder *v7; // esi@3
4363 int v8; // eax@7 2414 int v8; // eax@7
7132 { 5183 {
7133 // __debugbreak(); // should not fire outside decal builder 5184 // __debugbreak(); // should not fire outside decal builder
7134 return ::GetActorTintColor(tint, a4, a2, a5, a6); 5185 return ::GetActorTintColor(tint, a4, a2, a5, a6);
7135 } 5186 }
7136 5187
7137 /*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function 5188 /*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function
7138 { 5189 {
7139 int v5; // ebx@1 5190 int v5; // ebx@1
7140 int v6; // edi@1 5191 int v6; // edi@1
7141 int v8; // eax@7 5192 int v8; // eax@7
7142 float v9; // eax@12 5193 float v9; // eax@12
7247 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); 5298 this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT);
7248 5299
7249 }*/ 5300 }*/
7250 5301
7251 //----- (004A26BC) -------------------------------------------------------- 5302 //----- (004A26BC) --------------------------------------------------------
7252 void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) 5303 void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders)
7253 { 5304 {
7254 //RenderVertexSoft *pVertices; // esi@0 5305 //RenderVertexSoft *pVertices; // esi@0
7255 //int v7; // edi@1 5306 //int v7; // edi@1
7256 unsigned int v8; // ebx@1 5307 unsigned int v8; // ebx@1
7257 LightmapBuilder *v9; // esi@3 5308 LightmapBuilder *v9; // esi@3
7479 } 5530 }
7480 // 4A26BC: could not find valid save-restore pair for esi 5531 // 4A26BC: could not find valid save-restore pair for esi
7481 // 4D864C: using guessed type char byte_4D864C; 5532 // 4D864C: using guessed type char byte_4D864C;
7482 5533
7483 //----- (004A2DA3) -------------------------------------------------------- 5534 //----- (004A2DA3) --------------------------------------------------------
7484 void Render::DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) 5535 void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture)
7485 { 5536 {
7486 int v7; // eax@7 5537 int v7; // eax@7
7487 float v13; // ST3C_4@8 5538 float v13; // ST3C_4@8
7488 int i; 5539 int i;
7489 5540
7521 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); 5572 pVertices, uNumVertices, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT);
7522 } 5573 }
7523 } 5574 }
7524 5575
7525 //----- (004A2ED5) -------------------------------------------------------- 5576 //----- (004A2ED5) --------------------------------------------------------
7526 void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) 5577 void Render::_4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex)
7527 { 5578 {
7528 signed int v4; // edi@2 5579 signed int v4; // edi@2
7529 int v5; // eax@3 5580 int v5; // eax@3
7530 int v6; // edx@5 5581 int v6; // edx@5
7531 RenderVertexD3D3 *v7; // eax@6 5582 RenderVertexD3D3 *v7; // eax@6
7626 unsigned int v55; // eax@53 5677 unsigned int v55; // eax@53
7627 unsigned int v56; // eax@55 5678 unsigned int v56; // eax@55
7628 int v57; // ST10_4@55 5679 int v57; // ST10_4@55
7629 Texture *v58; // eax@55 5680 Texture *v58; // eax@55
7630 signed int v59; // [sp-4h] [bp-178h]@17 5681 signed int v59; // [sp-4h] [bp-178h]@17
7631 stru148 *v60; // [sp+0h] [bp-174h]@17 5682 struct Polygon *v60; // [sp+0h] [bp-174h]@17
7632 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 5683 IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17
7633 stru148 v62; // [sp+14h] [bp-160h]@6 5684 struct Polygon v62; // [sp+14h] [bp-160h]@6
7634 unsigned int v63; // [sp+120h] [bp-54h]@7 5685 unsigned int v63; // [sp+120h] [bp-54h]@7
7635 double v64; // [sp+124h] [bp-50h]@7 5686 double v64; // [sp+124h] [bp-50h]@7
7636 unsigned int v65; // [sp+128h] [bp-4Ch]@1 5687 unsigned int v65; // [sp+128h] [bp-4Ch]@1
7637 unsigned int v66; // [sp+12Ch] [bp-48h]@7 5688 unsigned int v66; // [sp+12Ch] [bp-48h]@7
7638 float v67; // [sp+130h] [bp-44h]@7 5689 float v67; // [sp+130h] [bp-44h]@7
9251 unsigned int v37; // [sp+8Ch] [bp-14h]@7 7302 unsigned int v37; // [sp+8Ch] [bp-14h]@7
9252 int v38; // [sp+90h] [bp-10h]@7 7303 int v38; // [sp+90h] [bp-10h]@7
9253 double v39; // [sp+94h] [bp-Ch]@6 7304 double v39; // [sp+94h] [bp-Ch]@6
9254 float v40; // [sp+9Ch] [bp-4h]@6 7305 float v40; // [sp+9Ch] [bp-4h]@6
9255 7306
7307 __debugbreak();
7308
9256 auto ecx0 = this; 7309 auto ecx0 = this;
9257 v3 = 0; 7310 v3 = 0;
9258 if ( ecx0->pRenderD3D ) 7311 if ( ecx0->pRenderD3D )
9259 { 7312 {
9260 v4 = a3; 7313 v4 = a3;