Mercurial > mm7
diff Engine/Graphics/Render.cpp @ 2572:d87bfbd3bb3b
Step towards unification of Texture and RGBTexture (class Image)
author | a.parshin |
---|---|
date | Sat, 05 Mar 2016 01:51:54 +0200 |
parents | 4d199006c716 |
children | 0c67be4ec900 |
line wrap: on
line diff
--- a/Engine/Graphics/Render.cpp Mon Oct 05 00:19:13 2015 +0200 +++ b/Engine/Graphics/Render.cpp Sat Mar 05 01:51:54 2016 +0200 @@ -6375,75 +6375,72 @@ __debugbreak(); } -void Render::DrawTextureNew(float u, float v, RGBTexture *a4) -{ - DrawTextureRGB(640 * u, 480 * v, a4); -} - -//----- (004A5BE3) -------------------------------------------------------- -void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) -{ - int v4; // edi@3 - unsigned __int16 *v6; // esi@3 - unsigned int v8; // eax@5 - unsigned int v9; // ebx@5 - unsigned int v11; // eax@7 - unsigned int v12; // ebx@8 - unsigned int v15; // eax@14 - int v19; // [sp+10h] [bp-8h]@3 - int v23; // [sp+28h] [bp+10h]@3 - - if ( this->uNumSceneBegins && a4 ) - { - v4 = a4->uWidth; - //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; - v6 = a4->pPixels; - v23 = a4->uHeight; - v19 = v4; - if ( this->bClip ) - { - if ( (signed int)uOutX < (signed int)this->uClipX ) - { - v8 = this->uClipX - uOutX; - v9 = uOutX - this->uClipX; - v8 *= 2; - v4 += v9; - v6 = (unsigned __int16 *)((char *)v6 + v8); - //v5 = (unsigned __int16 *)((char *)v5 + v8); - } - if ( (signed int)uOutY < (signed int)this->uClipY ) - { - v11 = this->uClipY - uOutY; - v6 += v19 * v11; - v23 += uOutY - this->uClipY; - //v5 += this->uTargetSurfacePitch * v11; - } - v12 = max(this->uClipX, uOutX); - if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) - { - v4 = this->uClipZ - max(this->uClipX, uOutX); - } - v15 = max(this->uClipY, uOutY); - if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) - { - v23 = this->uClipW - max(this->uClipY, uOutY); - } - } - - for (int y = 0; y < v23; y++) - { - for (int x = 0; x < v4; x++) - { - WritePixel16(uOutX + x, uOutY + y, *v6); - //*v5 = *v6; - //++v5; - ++v6; - } - v6 += v19 - v4; - //v5 += this->uTargetSurfacePitch - v4; - } - } -} + +void Render::DrawTextureNew(float u, float v, Image *bmp) +{ + unsigned __int16 *v6; // esi@3 + unsigned int v8; // eax@5 + unsigned int v11; // eax@7 + unsigned int v12; // ebx@8 + unsigned int v15; // eax@14 + int v19; // [sp+10h] [bp-8h]@3 + + if (!bmp) + return; + + unsigned int uOutX = 640 * u; + unsigned int uOutY = 480 * v; + + int width = bmp->GetWidth(); + int height = bmp->GetHeight(); + v6 = (unsigned __int16 *)bmp->GetPixels(IMAGE_FORMAT_R5G6B5); + + //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; + v19 = width; + if (this->bClip) + { + if ((signed int)uOutX < (signed int)this->uClipX) + { + v8 = this->uClipX - uOutX; + unsigned int v9 = uOutX - this->uClipX; + v8 *= 2; + width += v9; + v6 = (unsigned __int16 *)((char *)v6 + v8); + //v5 = (unsigned __int16 *)((char *)v5 + v8); + } + if ((signed int)uOutY < (signed int)this->uClipY) + { + v11 = this->uClipY - uOutY; + v6 += v19 * v11; + height += uOutY - this->uClipY; + //v5 += this->uTargetSurfacePitch * v11; + } + v12 = max(this->uClipX, uOutX); + if ((signed int)(width + v12) >(signed int)this->uClipZ) + { + width = this->uClipZ - max(this->uClipX, uOutX); + } + v15 = max(this->uClipY, uOutY); + if ((signed int)(v15 + height) > (signed int)this->uClipW) + { + height = this->uClipW - max(this->uClipY, uOutY); + } + } + + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + WritePixel16(uOutX + x, uOutY + y, *v6); + //*v5 = *v6; + //++v5; + ++v6; + } + v6 += v19 - width; + //v5 += this->uTargetSurfacePitch - v4; + } +} + //----- (004A5D33) -------------------------------------------------------- void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) @@ -6539,7 +6536,7 @@ if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) { //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; - v20 = a4->pLevelOfDetail0_prolly_alpha_mask; + v20 = a4->paletted_pixels; v5 = a4->uTextureWidth; v6 = a4->uTextureHeight; v19 = a4->uTextureWidth; @@ -7103,7 +7100,7 @@ { v5 = pTexture->uTextureHeight; //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; - v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; + v19 = pTexture->paletted_pixels; v20 = pTexture->uTextureWidth; v18 = pTexture->uTextureWidth; int clipped_out_x = a2; @@ -7202,7 +7199,7 @@ if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) { - v24 = a4->pLevelOfDetail0_prolly_alpha_mask; + v24 = a4->paletted_pixels; Width = a4->uTextureWidth; uHeight = a4->uTextureHeight; int clipped_out_x = x; @@ -7317,7 +7314,7 @@ { if ( a5->pPalette16 ) { - v28 = a4->pLevelOfDetail0_prolly_alpha_mask; + v28 = a4->paletted_pixels; Width = a4->uTextureWidth; Height = a4->uTextureHeight; int clipped_out_x = a2; @@ -7368,7 +7365,7 @@ { if ( *v28 ) { - v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); + v20 = *(&a5->paletted_pixels[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); if ( v20 >= a7 ) { if ( v20 <= a8 ) @@ -7386,39 +7383,6 @@ } v28 += a4->uTextureWidth - Width; } - - /*if ( v24 > 0 ) - { - v23 = v22 - v25; - do - { - for ( i = 0; i < v25; ++v28 ) - { - if ( *v28 ) - { - v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1)); - if ( v20 >= a7 ) - { - if ( v20 <= a8 ) - { - v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); - if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 ) - v21 = 2 * a8 - v21 - a7; - v9 = a5; - *v10 = a5->pPalette16[v21]; - } - } - } - ++i; - ++v10; - } - ++v27; - v10 += this->uTargetSurfacePitch - v25; - v28 += v23; - } - while ( v27 < v24 ); - }*/ - } } } @@ -7426,6 +7390,88 @@ } } + + + +void Render::DrawTextureAlphaNew(float u, float v, Image *img) +{ + int uHeight; // ebx@4 + unsigned int v11; // edx@9 + unsigned int v12; // esi@12 + unsigned int v13; // esi@15 + unsigned int v15; // esi@18 + //unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 + int uWidth; // [sp+1Ch] [bp-4h]@4 + + if (!uNumSceneBegins || !img) + return; + + uHeight = img->GetHeight(); + ///v19 = pTexture->paletted_pixels; + uWidth = img->GetWidth(); + + auto pixels = (const unsigned __int32 *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8); + + int uX = u * 640.0f; + int uY = v * 480.0f; + int clipped_out_x = uX; + int clipped_out_y = uY; + if (this->bClip) + { + if ((signed int)uX < (signed int)this->uClipX) + { + pixels += this->uClipX - uX; + uWidth += uX - this->uClipX; + clipped_out_x = uClipX; + } + + uHeight = img->GetHeight(); + if ((signed int)uY < (signed int)this->uClipY) + { + pixels += img->GetWidth() * (this->uClipY - uY); + uHeight = uY - this->uClipY + img->GetHeight(); + clipped_out_y = uClipY; + } + v11 = this->uClipX; + if ((signed int)this->uClipX < (signed int)uX) + v11 = uX; + + if ((signed int)(v11 + uWidth) >(signed int)this->uClipZ) + { + v12 = this->uClipX; + if ((signed int)this->uClipX < (signed int)uX) + v12 = uX; + uWidth = this->uClipZ - v12; + } + v13 = this->uClipY; + if ((signed int)this->uClipY < (signed int)uY) + v13 = uY; + + if ((signed int)(uHeight + v13) >(signed int)this->uClipW) + { + v15 = this->uClipY; + if ((signed int)this->uClipY < (signed int)uY) + v15 = uY; + uHeight = this->uClipW - v15; + } + } + + for (int y = 0; y < uHeight; ++y) + { + for (int x = 0; x < uWidth; ++x) + { + //if (*v19) + if (*pixels & 0xFF000000) + //WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); + WritePixel16(clipped_out_x + x, clipped_out_y + y, Color16((*pixels >> 16) & 0xFF, (*pixels >> 8) & 0xFF, *pixels & 0xFF)); + ++pixels; + } + pixels += img->GetWidth() - uWidth; + } +} + + + //----- (004A6274) -------------------------------------------------------- void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture *pTexture) { @@ -7444,7 +7490,7 @@ if ( pTexture->pPalette16 ) { uHeight = pTexture->uTextureHeight; - v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; + v19 = pTexture->paletted_pixels; uWidth = pTexture->uTextureWidth; int clipped_out_x = uX; @@ -7553,7 +7599,7 @@ v6 = uOutY; v7 = pTexture->uTextureHeight; pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; - uOutYa = pTexture->pLevelOfDetail0_prolly_alpha_mask; + uOutYa = pTexture->paletted_pixels; v8 = pTexture->uTextureWidth; v20 = pTexture->uTextureWidth; v19 = pTexture->uTextureWidth; @@ -7718,7 +7764,7 @@ { v5 = tex->uTextureHeight; //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; - v19 = tex->pLevelOfDetail0_prolly_alpha_mask; + v19 = tex->paletted_pixels; v20 = tex->uTextureWidth; v18 = tex->uTextureWidth;