Mercurial > mm7
comparison Render.cpp @ 2101:ee2724b9ca05
RasterLine2D fix and etc.
author | Ritor1 |
---|---|
date | Mon, 16 Dec 2013 18:43:42 +0600 |
parents | 7810cb3a5fb7 |
children | 0db53678ff48 |
comparison
equal
deleted
inserted
replaced
2100:e460ca22fe8a | 2101:ee2724b9ca05 |
---|---|
3559 pBeforePresentFunction = Present_NoColorKey; | 3559 pBeforePresentFunction = Present_NoColorKey; |
3560 goto LABEL_45; | 3560 goto LABEL_45; |
3561 } | 3561 } |
3562 | 3562 |
3563 //----- (004A0BEE) -------------------------------------------------------- | 3563 //----- (004A0BEE) -------------------------------------------------------- |
3564 char Render::RasterLine2D(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned __int16 uColor) | 3564 char Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) |
3565 { | 3565 { |
3566 unsigned int v8; // ebx@5 | 3566 signed int v8; // ebx@5 |
3567 unsigned int v10; // ecx@9 | 3567 signed int v10; // ecx@9 |
3568 unsigned int v11; // esi@13 | 3568 signed int v11; // esi@13 |
3569 int v12; // eax@17 | 3569 signed int v12; // eax@17 |
3570 int v13; // eax@21 | 3570 int v13; // eax@21 |
3571 int v16; // eax@27 | 3571 int v16; // eax@27 |
3572 signed __int64 v19; // qax@41 | 3572 signed int v19; // qax@41 |
3573 int v20; // edi@41 | 3573 int v20; // edi@41 |
3574 unsigned int v21; // edi@46 | 3574 unsigned int v21; // edi@46 |
3575 int v22; // esi@47 | 3575 int v22; // esi@47 |
3576 int v23; // ebx@47 | 3576 int v23; // ebx@47 |
3577 signed int v24; // edx@50 | 3577 signed int v24; // edx@50 |
3589 unsigned int uYa; // [sp+28h] [bp+Ch]@28 | 3589 unsigned int uYa; // [sp+28h] [bp+Ch]@28 |
3590 int uYb; // [sp+28h] [bp+Ch]@47 | 3590 int uYb; // [sp+28h] [bp+Ch]@47 |
3591 int uZa; // [sp+2Ch] [bp+10h]@38 | 3591 int uZa; // [sp+2Ch] [bp+10h]@38 |
3592 | 3592 |
3593 v36 = 0i64; | 3593 v36 = 0i64; |
3594 if ( (signed int)uX < this->raster_clip_x ) | 3594 if ( uX < this->raster_clip_x )// x выходит за рамки левой границы |
3595 HIDWORD(v36) = 8; | 3595 HIDWORD(v36) = 8; |
3596 if ( (signed int)uX > this->raster_clip_z ) | 3596 if ( uX > this->raster_clip_z )// x выходит за рамки правой границы |
3597 HIDWORD(v36) |= 4; | 3597 HIDWORD(v36) |= 4; |
3598 | 3598 |
3599 if ( uZ < this->raster_clip_x )// z выходит за рамки левой границы | |
3600 LODWORD(v36) = 8; | |
3601 if ( uZ > this->raster_clip_z )// z выходит за рамки правой границы | |
3602 LODWORD(v36) |= 4; | |
3603 | |
3604 if ( uY < this->raster_clip_y )// y выходит за рамки верхней границы | |
3605 HIDWORD(v36) |= 2; | |
3606 if ( uY > this->raster_clip_w )// y выходит за рамки нижней границы | |
3607 HIDWORD(v36) |= 1; | |
3608 | |
3609 if ( uW < this->raster_clip_y )// w выходит за рамки верхней границы | |
3610 LODWORD(v36) |= 2; | |
3611 if ( uW > this->raster_clip_w )// w выходит за рамки нижней границы | |
3612 LODWORD(v36) |= 1; | |
3613 | |
3599 v8 = uY; | 3614 v8 = uY; |
3600 if ( (signed int)uY < this->raster_clip_y ) | 3615 v11 = uW; |
3601 HIDWORD(v36) |= 2; | |
3602 if ( (signed int)uY > this->raster_clip_w ) | |
3603 HIDWORD(v36) |= 1; | |
3604 | |
3605 v10 = uZ; | 3616 v10 = uZ; |
3606 if ( (signed int)uZ < this->raster_clip_x ) | |
3607 LODWORD(v36) = 8; | |
3608 if ( (signed int)uZ > this->raster_clip_z ) | |
3609 LODWORD(v36) = v36 | 4; | |
3610 | |
3611 v11 = uW; | |
3612 if ( (signed int)uW < this->raster_clip_y ) | |
3613 LODWORD(v36) = v36 | 2; | |
3614 if ( (signed int)uW > this->raster_clip_w ) | |
3615 LODWORD(v36) = v36 | 1; | |
3616 | 3617 |
3617 LOBYTE(v12) = v36; | 3618 LOBYTE(v12) = v36; |
3618 if ( (unsigned int)v36 & HIDWORD(v36) ) | 3619 if ( (unsigned int)v36 & HIDWORD(v36) ) |
3619 return v12; | 3620 return v12; |
3620 if ( !v36 ) | 3621 if ( !v36 ) |
3644 v24 = -1; | 3645 v24 = -1; |
3645 } | 3646 } |
3646 v25 = 0; | 3647 v25 = 0; |
3647 | 3648 |
3648 v26 = (unsigned __int16 *)this->pTargetSurface; | 3649 v26 = (unsigned __int16 *)this->pTargetSurface; |
3649 int y = 0; | |
3650 int x = 0; | |
3651 if ( v26 ) | 3650 if ( v26 ) |
3652 { | 3651 { |
3653 if ( (signed int)uXa <= v23 )//рисуем вертикальную линию | 3652 if ( (signed int)uXa <= v23 )//рисуем вертикальную линию |
3654 { | 3653 { |
3655 v30 = v23 + 1; | 3654 v30 = v23 + 1; |
3656 if ( v30 > 0 ) | 3655 if ( v30 > 0 ) |
3657 { | 3656 { |
3658 v31 = 2 * v24; | 3657 v31 = 2 * v24; |
3659 v32 = 2 * v21; | 3658 v32 = 2 * v21; |
3660 v12 = (int)&v26[v12]; | 3659 v12 = (int)&v26[v12]; |
3660 int y = 0; | |
3661 int x = 0; | |
3661 for ( v30; v30; --v30 ) | 3662 for ( v30; v30; --v30 ) |
3662 { | 3663 { |
3663 v25 += uXa; | 3664 v25 += uXa; |
3664 //*(short *)v12 = uColor; | 3665 //*(short *)v12 = uColor; |
3665 //v12 += v32; | 3666 //v12 += v32; |
3681 } | 3682 } |
3682 } | 3683 } |
3683 else//рисуем горизонтальную линию | 3684 else//рисуем горизонтальную линию |
3684 { | 3685 { |
3685 v27 = uXa + 1; | 3686 v27 = uXa + 1; |
3686 int x = 0; | |
3687 if ( (signed int)(uXa + 1) > 0 ) | 3687 if ( (signed int)(uXa + 1) > 0 ) |
3688 { | 3688 { |
3689 v28 = 2 * v21; | 3689 v28 = 2 * v21; |
3690 v29 = 2 * v24; | 3690 v29 = 2 * v24; |
3691 int y = 0; | |
3692 int x = 0; | |
3691 v12 = (int)&v26[v12]; | 3693 v12 = (int)&v26[v12]; |
3692 for ( v27; v27; --v27 ) | 3694 for ( v27; v27; --v27 ) |
3693 { | 3695 { |
3694 v25 += uYb; | 3696 v25 += uYb; |
3695 //*(short *)v12 = uColor; | 3697 //*(short *)v12 = uColor; |
3717 } | 3719 } |
3718 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) | 3720 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 ) |
3719 { | 3721 { |
3720 if ( BYTE4(v36) & 8 ) | 3722 if ( BYTE4(v36) & 8 ) |
3721 { | 3723 { |
3722 v13 = (signed int)((uW - uY) * (this->raster_clip_x - uX)) / (signed int)(uZ - uX); | 3724 v13 = ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX); |
3723 v8 = v13 + uY; | 3725 v8 = v13 + uY; |
3724 uX = this->raster_clip_x; | 3726 uX = this->raster_clip_x; |
3725 goto LABEL_24; | 3727 goto LABEL_24; |
3726 } | 3728 } |
3727 v10 = this->raster_clip_x; | 3729 v10 = this->raster_clip_x; |
3728 v11 = (signed int)((uY - uW) * (this->raster_clip_x - uZ)) / (signed int)(uX - uZ) + uW; | 3730 v11 = ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ) + uW; |
3729 } | 3731 } |
3730 LABEL_24: | 3732 LABEL_24: |
3731 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) | 3733 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 ) |
3732 { | 3734 { |
3733 //v15 = this->raster_clip_z; | 3735 //v15 = this->raster_clip_z; |
3734 if ( BYTE4(v36) & 4 ) | 3736 if ( BYTE4(v36) & 4 ) |
3735 { | 3737 { |
3736 v8 += (signed int)((v11 - v8) * (this->raster_clip_z - uX)) / (signed int)(v10 - uX); | 3738 v8 += ((v11 - v8) * (this->raster_clip_z - uX)) / (v10 - uX); |
3737 uX = this->raster_clip_z; | 3739 uX = this->raster_clip_z; |
3738 } | 3740 } |
3739 else | 3741 else |
3740 { | 3742 { |
3741 v16 = (signed int)((v8 - v11) * (this->raster_clip_z - v10)) / (signed int)(uX - v10); | 3743 v16 = ((v8 - v11) * (this->raster_clip_z - v10)) / (uX - v10); |
3742 v10 = this->raster_clip_z; | 3744 v10 = this->raster_clip_z; |
3743 v11 += v16; | 3745 v11 += v16; |
3744 } | 3746 } |
3745 } | 3747 } |
3746 v37 = 0; | 3748 v37 = 0; |
3747 uYa = this->raster_clip_y; | 3749 uYa = this->raster_clip_y; |
3748 if ( (signed int)v8 < this->raster_clip_y ) | 3750 if ( v8 < this->raster_clip_y ) |
3749 v37 = 2; | 3751 v37 = 2; |
3750 if ( (signed int)v8 > this->raster_clip_w ) | 3752 if ( v8 > this->raster_clip_w ) |
3751 v37 |= 1; | 3753 v37 |= 1; |
3752 if ( (signed int)v11 >= this->raster_clip_y ) | 3754 |
3755 if ( v11 >= this->raster_clip_y ) | |
3753 v12 = 0; | 3756 v12 = 0; |
3754 else | 3757 else |
3755 v12 = 2; | 3758 v12 = 2; |
3756 if ( (signed int)v11 > this->raster_clip_w ) | 3759 if ( v11 > this->raster_clip_w ) |
3757 LOBYTE(v12) = v12 | 1; | 3760 LOBYTE(v12) = v12 | 1; |
3761 | |
3758 if ( !(v12 & v37) ) | 3762 if ( !(v12 & v37) ) |
3759 { | 3763 { |
3760 v12 ^= v37; | 3764 v12 ^= v37; |
3761 uZa = v12; | 3765 uZa = v12; |
3762 if ( v12 & 2 ) | 3766 if ( v12 & 2 ) |
3763 { | 3767 { |
3764 if ( v37 & 2 ) | 3768 if ( v37 & 2 ) |
3765 { | 3769 { |
3766 uX += (signed int)((v10 - uX) * (uYa - v8)) / (signed int)(v11 - v8); | 3770 uX += ((v10 - uX) * (uYa - v8)) / (v11 - v8); |
3767 LOBYTE(v12) = (char)this; | 3771 LOBYTE(v12) = (char)this; |
3768 v8 = this->raster_clip_y; | 3772 v8 = this->raster_clip_y; |
3769 } | 3773 } |
3770 else | 3774 else |
3771 { | 3775 { |
3772 v19 = (signed int)((uX - v10) * (uYa - v11)); | 3776 v19 = (uX - v10) * (uYa - v11); |
3773 v20 = v8 - v11; | 3777 v20 = v8 - v11; |
3774 v11 = uYa; | 3778 v11 = uYa; |
3775 v12 = v19 / v20; | 3779 v12 = v19 / v20; |
3776 v10 += v12; | 3780 v10 += v12; |
3777 } | 3781 } |
3778 } | 3782 } |
3779 if ( uZa & 1 ) | 3783 if ( uZa & 1 ) |
3780 { | 3784 { |
3781 if ( v37 & 1 ) | 3785 if ( v37 & 1 ) |
3782 { | 3786 { |
3783 uX += (signed int)((v10 - uX) * (this->raster_clip_w - v8)) / (signed int)(v11 - v8); | 3787 uX += ((v10 - uX) * (this->raster_clip_w - v8)) / (v11 - v8); |
3784 LOBYTE(v12) = (char)this; | 3788 LOBYTE(v12) = (char)this; |
3785 v8 = this->raster_clip_w; | 3789 v8 = this->raster_clip_w; |
3786 } | 3790 } |
3787 else | 3791 else |
3788 { | 3792 { |
3789 v12 = (signed int)((uX - v10) * (this->raster_clip_w - v11)) / (signed int)(v8 - v11); | 3793 v12 = ((uX - v10) * (this->raster_clip_w - v11)) / (v8 - v11); |
3790 v11 = this->raster_clip_w; | 3794 v11 = this->raster_clip_w; |
3791 v10 += v12; | 3795 v10 += v12; |
3792 } | 3796 } |
3793 } | 3797 } |
3794 goto LABEL_46; | 3798 goto LABEL_46; |
7836 { | 7840 { |
7837 for (int x = 0; x < v25; ++x) | 7841 for (int x = 0; x < v25; ++x) |
7838 { | 7842 { |
7839 if ( *v28 ) | 7843 if ( *v28 ) |
7840 { | 7844 { |
7841 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[i & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); | 7845 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); |
7842 if ( v20 >= a7 ) | 7846 if ( v20 >= a7 ) |
7843 { | 7847 { |
7844 if ( v20 <= a8 ) | 7848 if ( v20 <= a8 ) |
7845 { | 7849 { |
7846 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); | 7850 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); |