comparison Render.cpp @ 2199:3445abad44c5

RasterLine2D()
author Ritor1
date Sun, 02 Feb 2014 21:53:29 +0600
parents d9caf2b3d8d5
children 15a327be07e2
comparison
equal deleted inserted replaced
2198:d9caf2b3d8d5 2199:3445abad44c5
3658 //----- (004A0BEE) -------------------------------------------------------- 3658 //----- (004A0BEE) --------------------------------------------------------
3659 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor) 3659 void Render::RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor)
3660 { 3660 {
3661 signed int lower_bound; // eax@17 3661 signed int lower_bound; // eax@17
3662 signed int left_bound; 3662 signed int left_bound;
3663 //signed int v19; // qax@41
3664 //int v20; // edi@41
3665 unsigned int v21; // edi@46 3663 unsigned int v21; // edi@46
3666 int v22; // esi@47 3664 int v22; // esi@47
3667 int v23; // ebx@47 3665 int v23; // ebx@47
3668 signed int v24; // edx@50 3666 signed int v24; // edx@50
3669 signed int v25; // esi@52 3667 signed int v25; // esi@52
3675 int v31; // edx@61 3673 int v31; // edx@61
3676 int v32; // edi@61 3674 int v32; // edi@61
3677 __int64 v36; // [sp+14h] [bp-8h]@1 3675 __int64 v36; // [sp+14h] [bp-8h]@1
3678 signed int upper_bound; // [sp+18h] [bp-4h]@28 3676 signed int upper_bound; // [sp+18h] [bp-4h]@28
3679 unsigned int uXa; // [sp+24h] [bp+8h]@49 3677 unsigned int uXa; // [sp+24h] [bp+8h]@49
3680 //unsigned int uYa; // [sp+28h] [bp+Ch]@28
3681 int uYb; // [sp+28h] [bp+Ch]@47 3678 int uYb; // [sp+28h] [bp+Ch]@47
3682 //int uZa; // [sp+2Ch] [bp+10h]@38
3683 bool left_border;
3684 3679
3685 v36 = 0i64; 3680 v36 = 0i64;
3686 if ( uX < this->raster_clip_x )// x выходит за рамки левой границы 3681 if ( uX < this->raster_clip_x )// x выходит за рамки левой границы
3687 HIDWORD(v36) = 8; //left_border = true; 3682 HIDWORD(v36) = 8; //left_border = true;
3688 if ( uX > this->raster_clip_z )// x выходит за рамки правой границы 3683 if ( uX > this->raster_clip_z )// x выходит за рамки правой границы
3705 3700
3706 //LOBYTE(v12) = v36; 3701 //LOBYTE(v12) = v36;
3707 if ( (unsigned int)v36 & HIDWORD(v36) ) 3702 if ( (unsigned int)v36 & HIDWORD(v36) )
3708 return; 3703 return;
3709 3704
3710 if ( !v36 ) //полностью в рамках 3705 if ( v36 ) //не полностью в рамках
3711 { 3706 {
3712 LABEL_46: 3707 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left and right(левая и правая)
3713 v21 = pRenderer->uTargetSurfacePitch; 3708 {
3714 if ( pRenderer->uTargetSurfacePitch ) 3709 if ( BYTE4(v36) & 8 )//left_border = true;
3715 { 3710 {
3716 //v12 = uX + uY * pRenderer->uTargetSurfacePitch; 3711 uY += ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX);
3717 v22 = uW - uY; 3712 uX = this->raster_clip_x;
3718 v23 = v22;
3719 uYb = v22;
3720 if ( v22 < 0 )
3721 {
3722 v23 = -v22;
3723 uYb = -v22;
3724 v21 = -pRenderer->uTargetSurfacePitch;
3725 }
3726 uXa = uZ - uX;
3727 if ( (uXa & 0x80000000u) == 0 )
3728 {
3729 v24 = 1;
3730 } 3713 }
3731 else 3714 else
3732 { 3715 {
3733 uXa = -uXa; 3716 uZ = this->raster_clip_x;
3734 v24 = -1; 3717 uW += ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ);
3735 } 3718 }
3736 v25 = 0; 3719 }
3737 3720 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
3738 v26 = (unsigned __int16 *)this->pTargetSurface; 3721 {
3739 if ( v26 ) 3722 if ( BYTE4(v36) & 4 ) //right_border = true
3740 { 3723 {
3741 if ( (signed int)uXa <= v23 )//рисуем вертикальную линию 3724 uY += ((uW - uY) * (this->raster_clip_z - uX)) / (uZ - uX);
3725 uX = this->raster_clip_z;
3726 }
3727 else
3728 {
3729 uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ);
3730 uZ = this->raster_clip_z;
3731 }
3732 }
3733 upper_bound = 0;
3734 if ( uY < this->raster_clip_y )
3735 upper_bound = 2;
3736 if ( uY > this->raster_clip_w )
3737 upper_bound |= 1;
3738
3739 lower_bound = 0;
3740 if ( uW < this->raster_clip_y )
3741 lower_bound = 2;
3742 if ( uW > this->raster_clip_w )
3743 lower_bound |= 1;
3744
3745 if ( !(lower_bound & upper_bound) )//for up and down(для верха и низа)
3746 {
3747 lower_bound ^= upper_bound;
3748 if ( lower_bound & 2 )
3749 {
3750 if ( upper_bound & 2 )
3742 { 3751 {
3743 v30 = v23 + 1; 3752 uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY);
3744 if ( v30 > 0 ) 3753 uY = this->raster_clip_y;
3754 }
3755 else
3756 {
3757 uZ += (uX - uZ) * (this->raster_clip_y - uW) / (uY - uW);
3758 uW = this->raster_clip_y;
3759 }
3760 }
3761 if ( lower_bound & 1 )
3762 {
3763 if ( upper_bound & 1 )
3764 {
3765 uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY);
3766 uY = this->raster_clip_w;
3767 }
3768 else
3769 {
3770 uZ += ((uX - uZ) * (this->raster_clip_w - uW)) / (uY - uW);
3771 uW = this->raster_clip_w;
3772 }
3773 }
3774 }
3775 }
3776 v21 = pRenderer->uTargetSurfacePitch;
3777 if ( pRenderer->uTargetSurfacePitch )
3778 {
3779 //v12 = uX + uY * pRenderer->uTargetSurfacePitch;
3780 v22 = uW - uY;
3781 v23 = v22;
3782 uYb = v22;
3783 if ( v22 < 0 )
3784 {
3785 v23 = -v22;
3786 uYb = -v22;
3787 v21 = -pRenderer->uTargetSurfacePitch;
3788 }
3789 uXa = uZ - uX;
3790 if ((signed)(uZ - uX) >= 0)
3791 v24 = 1;
3792 else
3793 {
3794 uXa = -uXa;
3795 v24 = -1;
3796 }
3797 v25 = 0;
3798
3799 v26 = (unsigned __int16 *)this->pTargetSurface;
3800 if ( v26 )
3801 {
3802 if ( (signed int)uXa <= v23 )//рисуем вертикальную линию
3803 {
3804 v30 = v23 + 1;
3805 if ( v30 > 0 )
3806 {
3807 v31 = 2 * v24;
3808 v32 = 2 * v21;
3809 //v12 = (int)&v26[v12];
3810 int y = 0;
3811 int x = 0;
3812 for ( v30; v30; --v30 )
3745 { 3813 {
3746 v31 = 2 * v24; 3814 v25 += uXa;
3747 v32 = 2 * v21; 3815 //*(short *)v12 = uColor;
3748 //v12 = (int)&v26[v12]; 3816 //v12 += v32;
3749 int y = 0; 3817 WritePixel16(uX + x, uY + y, uColor);
3750 int x = 0; 3818 if ( v32 >= 0 )
3751 for ( v30; v30; --v30 ) 3819 y += 1;
3820 else
3821 y -= 1;
3822 if ( v25 > 0 )
3752 { 3823 {
3753 v25 += uXa; 3824 v25 -= uYb;
3754 //*(short *)v12 = uColor; 3825 //v12 += v31;
3755 //v12 += v32; 3826 if ( v31 >= 0 )
3756 WritePixel16(uX + x, uY + y, uColor); 3827 x += 1;
3757 if ( v32 >= 0 ) 3828 else
3829 x -= 1;
3830 }
3831 }
3832 }
3833 }
3834 else//рисуем горизонтальную линию
3835 {
3836 v27 = uXa + 1;
3837 if ( (signed int)(uXa + 1) > 0 )
3838 {
3839 v28 = 2 * v21;
3840 v29 = 2 * v24;
3841 int y = 0;
3842 int x = 0;
3843 //v12 = (int)&v26[v12];
3844 for ( v27; v27; --v27 )
3845 {
3846 v25 += uYb;
3847 //*(short *)v12 = uColor;
3848 //v12 += v29;
3849 WritePixel16(uX + x, uY + y, uColor);
3850 if ( v29 >= 0 )
3851 x += 1;
3852 else
3853 x -= 1;
3854 if ( v25 > (signed int)uXa )
3855 {
3856 v25 -= uXa;
3857 //v12 += v28;
3858 if ( v28 >= 0 )
3758 y += 1; 3859 y += 1;
3759 else 3860 else
3760 y -= 1; 3861 y -= 1;
3761 if ( v25 > 0 )
3762 {
3763 v25 -= uYb;
3764 //v12 += v31;
3765 if ( v31 >= 0 )
3766 x += 1;
3767 else
3768 x -= 1;
3769 }
3770 } 3862 }
3771 } 3863 }
3772 } 3864 }
3773 else//рисуем горизонтальную линию 3865 }
3774 { 3866 }
3775 v27 = uXa + 1;
3776 if ( (signed int)(uXa + 1) > 0 )
3777 {
3778 v28 = 2 * v21;
3779 v29 = 2 * v24;
3780 int y = 0;
3781 int x = 0;
3782 //v12 = (int)&v26[v12];
3783 for ( v27; v27; --v27 )
3784 {
3785 v25 += uYb;
3786 //*(short *)v12 = uColor;
3787 //v12 += v29;
3788 WritePixel16(uX + x, uY + y, uColor);
3789 if ( v29 >= 0 )
3790 x += 1;
3791 else
3792 x -= 1;
3793 if ( v25 > (signed int)uXa )
3794 {
3795 v25 -= uXa;
3796 //v12 += v28;
3797 if ( v28 >= 0 )
3798 y += 1;
3799 else
3800 y -= 1;
3801 }
3802 }
3803 }
3804 }
3805 }
3806 }
3807 return;
3808 }
3809
3810 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 8 )//for left and right(левая и правая)
3811 {
3812 if ( BYTE4(v36) & 8 )//left_border = true;
3813 {
3814 uY += ((uW - uY) * (this->raster_clip_x - uX)) / (uZ - uX);
3815 uX = this->raster_clip_x;
3816 }
3817 else
3818 {
3819 uZ = this->raster_clip_x;
3820 uW += ((uY - uW) * (this->raster_clip_x - uZ)) / (uX - uZ);
3821 }
3822 }
3823 if ( (BYTE4(v36) ^ (unsigned __int8)v36) & 4 )
3824 {
3825 if ( BYTE4(v36) & 4 ) //right_border = true
3826 {
3827 uY += ((uW - uY) * (this->raster_clip_z - uX)) / (uZ - uX);
3828 uX = this->raster_clip_z;
3829 }
3830 else
3831 {
3832 uW += ((uY - uW) * (this->raster_clip_z - uZ)) / (uX - uZ);
3833 uZ = this->raster_clip_z;
3834 }
3835 }
3836
3837 upper_bound = 0;
3838 if ( uY < this->raster_clip_y )
3839 upper_bound = 2;
3840 if ( uY > this->raster_clip_w )
3841 upper_bound |= 1;
3842
3843 lower_bound = 0;
3844 if ( uW < this->raster_clip_y )
3845 lower_bound = 2;
3846 if ( uW > this->raster_clip_w )
3847 lower_bound |= 1;
3848
3849 if ( !(lower_bound & upper_bound) )//for up and down(для верха и низа)
3850 {
3851 lower_bound ^= upper_bound;
3852 if ( lower_bound & 2 )
3853 {
3854 if ( upper_bound & 2 )
3855 {
3856 uX += ((uZ - uX) * (this->raster_clip_y - uY)) / (uW - uY);
3857 uY = this->raster_clip_y;
3858 }
3859 else
3860 {
3861 uZ += (uX - uZ) * (this->raster_clip_y - uW) / (uY - uW);
3862 uW = this->raster_clip_y;
3863 }
3864 }
3865 if ( lower_bound & 1 )
3866 {
3867 if ( upper_bound & 1 )
3868 {
3869 uX += ((uZ - uX) * (this->raster_clip_w - uY)) / (uW - uY);
3870 uY = this->raster_clip_w;
3871 }
3872 else
3873 {
3874 uZ += ((uX - uZ) * (this->raster_clip_w - uW)) / (uY - uW);
3875 uW = this->raster_clip_w;
3876 }
3877 }
3878 goto LABEL_46;
3879 } 3867 }
3880 return; 3868 return;
3881 } 3869 }
3882 3870
3883 //----- (004A0E80) -------------------------------------------------------- 3871 //----- (004A0E80) --------------------------------------------------------