comparison 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
comparison
equal deleted inserted replaced
2571:cf29f444ddd7 2572:d87bfbd3bb3b
6373 void Render::DrawTextureNew(float u, float v, Texture *a4) 6373 void Render::DrawTextureNew(float u, float v, Texture *a4)
6374 { 6374 {
6375 __debugbreak(); 6375 __debugbreak();
6376 } 6376 }
6377 6377
6378 void Render::DrawTextureNew(float u, float v, RGBTexture *a4) 6378
6379 { 6379 void Render::DrawTextureNew(float u, float v, Image *bmp)
6380 DrawTextureRGB(640 * u, 480 * v, a4); 6380 {
6381 } 6381 unsigned __int16 *v6; // esi@3
6382 6382 unsigned int v8; // eax@5
6383 //----- (004A5BE3) -------------------------------------------------------- 6383 unsigned int v11; // eax@7
6384 void Render::DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4) 6384 unsigned int v12; // ebx@8
6385 { 6385 unsigned int v15; // eax@14
6386 int v4; // edi@3 6386 int v19; // [sp+10h] [bp-8h]@3
6387 unsigned __int16 *v6; // esi@3 6387
6388 unsigned int v8; // eax@5 6388 if (!bmp)
6389 unsigned int v9; // ebx@5 6389 return;
6390 unsigned int v11; // eax@7 6390
6391 unsigned int v12; // ebx@8 6391 unsigned int uOutX = 640 * u;
6392 unsigned int v15; // eax@14 6392 unsigned int uOutY = 480 * v;
6393 int v19; // [sp+10h] [bp-8h]@3 6393
6394 int v23; // [sp+28h] [bp+10h]@3 6394 int width = bmp->GetWidth();
6395 6395 int height = bmp->GetHeight();
6396 if ( this->uNumSceneBegins && a4 ) 6396 v6 = (unsigned __int16 *)bmp->GetPixels(IMAGE_FORMAT_R5G6B5);
6397 { 6397
6398 v4 = a4->uWidth; 6398 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch];
6399 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; 6399 v19 = width;
6400 v6 = a4->pPixels; 6400 if (this->bClip)
6401 v23 = a4->uHeight; 6401 {
6402 v19 = v4; 6402 if ((signed int)uOutX < (signed int)this->uClipX)
6403 if ( this->bClip ) 6403 {
6404 { 6404 v8 = this->uClipX - uOutX;
6405 if ( (signed int)uOutX < (signed int)this->uClipX ) 6405 unsigned int v9 = uOutX - this->uClipX;
6406 { 6406 v8 *= 2;
6407 v8 = this->uClipX - uOutX; 6407 width += v9;
6408 v9 = uOutX - this->uClipX; 6408 v6 = (unsigned __int16 *)((char *)v6 + v8);
6409 v8 *= 2; 6409 //v5 = (unsigned __int16 *)((char *)v5 + v8);
6410 v4 += v9; 6410 }
6411 v6 = (unsigned __int16 *)((char *)v6 + v8); 6411 if ((signed int)uOutY < (signed int)this->uClipY)
6412 //v5 = (unsigned __int16 *)((char *)v5 + v8); 6412 {
6413 } 6413 v11 = this->uClipY - uOutY;
6414 if ( (signed int)uOutY < (signed int)this->uClipY ) 6414 v6 += v19 * v11;
6415 { 6415 height += uOutY - this->uClipY;
6416 v11 = this->uClipY - uOutY; 6416 //v5 += this->uTargetSurfacePitch * v11;
6417 v6 += v19 * v11; 6417 }
6418 v23 += uOutY - this->uClipY; 6418 v12 = max(this->uClipX, uOutX);
6419 //v5 += this->uTargetSurfacePitch * v11; 6419 if ((signed int)(width + v12) >(signed int)this->uClipZ)
6420 } 6420 {
6421 v12 = max(this->uClipX, uOutX); 6421 width = this->uClipZ - max(this->uClipX, uOutX);
6422 if ( (signed int)(v4 + v12) > (signed int)this->uClipZ ) 6422 }
6423 { 6423 v15 = max(this->uClipY, uOutY);
6424 v4 = this->uClipZ - max(this->uClipX, uOutX); 6424 if ((signed int)(v15 + height) > (signed int)this->uClipW)
6425 } 6425 {
6426 v15 = max(this->uClipY, uOutY); 6426 height = this->uClipW - max(this->uClipY, uOutY);
6427 if ( (signed int)(v15 + v23) > (signed int)this->uClipW ) 6427 }
6428 { 6428 }
6429 v23 = this->uClipW - max(this->uClipY, uOutY); 6429
6430 } 6430 for (int y = 0; y < height; y++)
6431 } 6431 {
6432 6432 for (int x = 0; x < width; x++)
6433 for (int y = 0; y < v23; y++) 6433 {
6434 { 6434 WritePixel16(uOutX + x, uOutY + y, *v6);
6435 for (int x = 0; x < v4; x++) 6435 //*v5 = *v6;
6436 { 6436 //++v5;
6437 WritePixel16(uOutX + x, uOutY + y, *v6); 6437 ++v6;
6438 //*v5 = *v6; 6438 }
6439 //++v5; 6439 v6 += v19 - width;
6440 ++v6; 6440 //v5 += this->uTargetSurfacePitch - v4;
6441 } 6441 }
6442 v6 += v19 - v4; 6442 }
6443 //v5 += this->uTargetSurfacePitch - v4; 6443
6444 }
6445 }
6446 }
6447 6444
6448 //----- (004A5D33) -------------------------------------------------------- 6445 //----- (004A5D33) --------------------------------------------------------
6449 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) 6446 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture)
6450 { 6447 {
6451 //unsigned __int16 *v7; // ebx@3 6448 //unsigned __int16 *v7; // ebx@3
6537 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4 6534 unsigned __int8 *v20; // [sp+1Ch] [bp-4h]@4
6538 6535
6539 if ( this->uNumSceneBegins && a4 && a4->pPalette16 ) 6536 if ( this->uNumSceneBegins && a4 && a4->pPalette16 )
6540 { 6537 {
6541 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; 6538 //v4 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
6542 v20 = a4->pLevelOfDetail0_prolly_alpha_mask; 6539 v20 = a4->paletted_pixels;
6543 v5 = a4->uTextureWidth; 6540 v5 = a4->uTextureWidth;
6544 v6 = a4->uTextureHeight; 6541 v6 = a4->uTextureHeight;
6545 v19 = a4->uTextureWidth; 6542 v19 = a4->uTextureWidth;
6546 v18 = a4->uTextureWidth; 6543 v18 = a4->uTextureWidth;
6547 int clipped_out_x = a2; 6544 int clipped_out_x = a2;
7101 7098
7102 if ( pTexture->pPalette16 ) 7099 if ( pTexture->pPalette16 )
7103 { 7100 {
7104 v5 = pTexture->uTextureHeight; 7101 v5 = pTexture->uTextureHeight;
7105 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; 7102 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch];
7106 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; 7103 v19 = pTexture->paletted_pixels;
7107 v20 = pTexture->uTextureWidth; 7104 v20 = pTexture->uTextureWidth;
7108 v18 = pTexture->uTextureWidth; 7105 v18 = pTexture->uTextureWidth;
7109 int clipped_out_x = a2; 7106 int clipped_out_x = a2;
7110 int clipped_out_y = a3; 7107 int clipped_out_y = a3;
7111 if ( this->bClip ) 7108 if ( this->bClip )
7200 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6 7197 unsigned __int8 *v24; // [sp+14h] [bp-4h]@6
7201 int Width; // [sp+2Ch] [bp+14h]@6 7198 int Width; // [sp+2Ch] [bp+14h]@6
7202 7199
7203 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 ) 7200 if ( this->uNumSceneBegins && a4 && a4->pPalette16 && a5 && a5->pPalette16 )
7204 { 7201 {
7205 v24 = a4->pLevelOfDetail0_prolly_alpha_mask; 7202 v24 = a4->paletted_pixels;
7206 Width = a4->uTextureWidth; 7203 Width = a4->uTextureWidth;
7207 uHeight = a4->uTextureHeight; 7204 uHeight = a4->uTextureHeight;
7208 int clipped_out_x = x; 7205 int clipped_out_x = x;
7209 int clipped_out_y = y; 7206 int clipped_out_y = y;
7210 if ( this->bClip ) 7207 if ( this->bClip )
7315 { 7312 {
7316 if ( a5 ) 7313 if ( a5 )
7317 { 7314 {
7318 if ( a5->pPalette16 ) 7315 if ( a5->pPalette16 )
7319 { 7316 {
7320 v28 = a4->pLevelOfDetail0_prolly_alpha_mask; 7317 v28 = a4->paletted_pixels;
7321 Width = a4->uTextureWidth; 7318 Width = a4->uTextureWidth;
7322 Height = a4->uTextureHeight; 7319 Height = a4->uTextureHeight;
7323 int clipped_out_x = a2; 7320 int clipped_out_x = a2;
7324 int clipped_out_y = a3; 7321 int clipped_out_y = a3;
7325 if ( this->bClip ) 7322 if ( this->bClip )
7366 { 7363 {
7367 for (int x = 0; x < Width; ++x) 7364 for (int x = 0; x < Width; ++x)
7368 { 7365 {
7369 if ( *v28 ) 7366 if ( *v28 )
7370 { 7367 {
7371 v20 = *(&a5->pLevelOfDetail0_prolly_alpha_mask[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1)); 7368 v20 = *(&a5->paletted_pixels[x & a5->uWidthMinus1] + a5->uTextureWidth * (v27 & a5->uHeightMinus1));
7372 if ( v20 >= a7 ) 7369 if ( v20 >= a7 )
7373 { 7370 {
7374 if ( v20 <= a8 ) 7371 if ( v20 <= a8 )
7375 { 7372 {
7376 v21 = a7 + (a6 + v20) % (2 * (a8 - a7)); 7373 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
7384 } 7381 }
7385 v28++; 7382 v28++;
7386 } 7383 }
7387 v28 += a4->uTextureWidth - Width; 7384 v28 += a4->uTextureWidth - Width;
7388 } 7385 }
7389
7390 /*if ( v24 > 0 )
7391 {
7392 v23 = v22 - v25;
7393 do
7394 {
7395 for ( i = 0; i < v25; ++v28 )
7396 {
7397 if ( *v28 )
7398 {
7399 v20 = *(&v9->pLevelOfDetail0_prolly_alpha_mask[i & v9->uWidthMinus1] + v9->uTextureWidth * (v27 & v9->uHeightMinus1));
7400 if ( v20 >= a7 )
7401 {
7402 if ( v20 <= a8 )
7403 {
7404 v21 = a7 + (a6 + v20) % (2 * (a8 - a7));
7405 if ( (a6 + v20) % (2 * (a8 - a7)) >= a8 - a7 )
7406 v21 = 2 * a8 - v21 - a7;
7407 v9 = a5;
7408 *v10 = a5->pPalette16[v21];
7409 }
7410 }
7411 }
7412 ++i;
7413 ++v10;
7414 }
7415 ++v27;
7416 v10 += this->uTargetSurfacePitch - v25;
7417 v28 += v23;
7418 }
7419 while ( v27 < v24 );
7420 }*/
7421
7422 } 7386 }
7423 } 7387 }
7424 } 7388 }
7425 } 7389 }
7426 } 7390 }
7427 } 7391 }
7392
7393
7394
7395
7396 void Render::DrawTextureAlphaNew(float u, float v, Image *img)
7397 {
7398 int uHeight; // ebx@4
7399 unsigned int v11; // edx@9
7400 unsigned int v12; // esi@12
7401 unsigned int v13; // esi@15
7402 unsigned int v15; // esi@18
7403 //unsigned __int8 *v19; // [sp+18h] [bp-8h]@4
7404 int uWidth; // [sp+1Ch] [bp-4h]@4
7405
7406 if (!uNumSceneBegins || !img)
7407 return;
7408
7409 uHeight = img->GetHeight();
7410 ///v19 = pTexture->paletted_pixels;
7411 uWidth = img->GetWidth();
7412
7413 auto pixels = (const unsigned __int32 *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8);
7414
7415 int uX = u * 640.0f;
7416 int uY = v * 480.0f;
7417 int clipped_out_x = uX;
7418 int clipped_out_y = uY;
7419 if (this->bClip)
7420 {
7421 if ((signed int)uX < (signed int)this->uClipX)
7422 {
7423 pixels += this->uClipX - uX;
7424 uWidth += uX - this->uClipX;
7425 clipped_out_x = uClipX;
7426 }
7427
7428 uHeight = img->GetHeight();
7429 if ((signed int)uY < (signed int)this->uClipY)
7430 {
7431 pixels += img->GetWidth() * (this->uClipY - uY);
7432 uHeight = uY - this->uClipY + img->GetHeight();
7433 clipped_out_y = uClipY;
7434 }
7435 v11 = this->uClipX;
7436 if ((signed int)this->uClipX < (signed int)uX)
7437 v11 = uX;
7438
7439 if ((signed int)(v11 + uWidth) >(signed int)this->uClipZ)
7440 {
7441 v12 = this->uClipX;
7442 if ((signed int)this->uClipX < (signed int)uX)
7443 v12 = uX;
7444 uWidth = this->uClipZ - v12;
7445 }
7446 v13 = this->uClipY;
7447 if ((signed int)this->uClipY < (signed int)uY)
7448 v13 = uY;
7449
7450 if ((signed int)(uHeight + v13) >(signed int)this->uClipW)
7451 {
7452 v15 = this->uClipY;
7453 if ((signed int)this->uClipY < (signed int)uY)
7454 v15 = uY;
7455 uHeight = this->uClipW - v15;
7456 }
7457 }
7458
7459 for (int y = 0; y < uHeight; ++y)
7460 {
7461 for (int x = 0; x < uWidth; ++x)
7462 {
7463 //if (*v19)
7464 if (*pixels & 0xFF000000)
7465 //WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]);
7466 WritePixel16(clipped_out_x + x, clipped_out_y + y, Color16((*pixels >> 16) & 0xFF, (*pixels >> 8) & 0xFF, *pixels & 0xFF));
7467 ++pixels;
7468 }
7469 pixels += img->GetWidth() - uWidth;
7470 }
7471 }
7472
7473
7428 7474
7429 //----- (004A6274) -------------------------------------------------------- 7475 //----- (004A6274) --------------------------------------------------------
7430 void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture *pTexture) 7476 void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture *pTexture)
7431 { 7477 {
7432 int uHeight; // ebx@4 7478 int uHeight; // ebx@4
7442 if ( pTexture ) 7488 if ( pTexture )
7443 { 7489 {
7444 if ( pTexture->pPalette16 ) 7490 if ( pTexture->pPalette16 )
7445 { 7491 {
7446 uHeight = pTexture->uTextureHeight; 7492 uHeight = pTexture->uTextureHeight;
7447 v19 = pTexture->pLevelOfDetail0_prolly_alpha_mask; 7493 v19 = pTexture->paletted_pixels;
7448 uWidth = pTexture->uTextureWidth; 7494 uWidth = pTexture->uTextureWidth;
7449 7495
7450 int clipped_out_x = uX; 7496 int clipped_out_x = uX;
7451 int clipped_out_y = uY; 7497 int clipped_out_y = uY;
7452 if ( this->bClip ) 7498 if ( this->bClip )
7551 if ( pTexture ) 7597 if ( pTexture )
7552 { 7598 {
7553 v6 = uOutY; 7599 v6 = uOutY;
7554 v7 = pTexture->uTextureHeight; 7600 v7 = pTexture->uTextureHeight;
7555 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; 7601 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY];
7556 uOutYa = pTexture->pLevelOfDetail0_prolly_alpha_mask; 7602 uOutYa = pTexture->paletted_pixels;
7557 v8 = pTexture->uTextureWidth; 7603 v8 = pTexture->uTextureWidth;
7558 v20 = pTexture->uTextureWidth; 7604 v20 = pTexture->uTextureWidth;
7559 v19 = pTexture->uTextureWidth; 7605 v19 = pTexture->uTextureWidth;
7560 if ( this->bClip ) 7606 if ( this->bClip )
7561 { 7607 {
7716 { 7762 {
7717 if ( tex->pPalette16 ) 7763 if ( tex->pPalette16 )
7718 { 7764 {
7719 v5 = tex->uTextureHeight; 7765 v5 = tex->uTextureHeight;
7720 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch]; 7766 //pTarget = &this->pTargetSurface[uX + uY * this->uTargetSurfacePitch];
7721 v19 = tex->pLevelOfDetail0_prolly_alpha_mask; 7767 v19 = tex->paletted_pixels;
7722 v20 = tex->uTextureWidth; 7768 v20 = tex->uTextureWidth;
7723 v18 = tex->uTextureWidth; 7769 v18 = tex->uTextureWidth;
7724 7770
7725 int clipped_out_x = x; 7771 int clipped_out_x = x;
7726 int clipped_out_y = y; 7772 int clipped_out_y = y;