Mercurial > mm7
comparison Engine/Graphics/Render.cpp @ 2574:dd36326a9994
More texture refactoring
GetLeather -> DrawTextureCustomHeight
author | a.parshin |
---|---|
date | Mon, 07 Mar 2016 03:48:40 +0200 |
parents | 0c67be4ec900 |
children | a76d408c5132 |
comparison
equal
deleted
inserted
replaced
2573:0c67be4ec900 | 2574:dd36326a9994 |
---|---|
304 { | 304 { |
305 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; | 305 pTilePolygon = &array_77EC08[pODMRenderParams->uNumPolygons]; |
306 pTilePolygon->flags = 0; | 306 pTilePolygon->flags = 0; |
307 pTilePolygon->field_32 = 0; | 307 pTilePolygon->field_32 = 0; |
308 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); | 308 pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); |
309 pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; | 309 pTilePolygon->pTexture = (Texture_MM7 *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; |
310 if (pTilePolygon->uTileBitmapID == 0xFFFF) | 310 if (pTilePolygon->uTileBitmapID == 0xFFFF) |
311 continue; | 311 continue; |
312 | 312 |
313 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); | 313 //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); |
314 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); | 314 pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); |
5144 } | 5144 } |
5145 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); | 5145 pRenderer->DrawIndoorSkyPolygon(pNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[(signed __int16)pSkyPolygon.uTileBitmapID]); |
5146 } | 5146 } |
5147 | 5147 |
5148 //----- (004A2FC0) -------------------------------------------------------- | 5148 //----- (004A2FC0) -------------------------------------------------------- |
5149 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) | 5149 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture_MM7 *pTex, int uPackedID, unsigned int uColor, int a8) |
5150 { | 5150 { |
5151 if (!uNumD3DSceneBegins || uNumVertices < 3) | 5151 if (!uNumD3DSceneBegins || uNumVertices < 3) |
5152 return; | 5152 return; |
5153 | 5153 |
5154 int sCorrectedColor = uColor; | 5154 int sCorrectedColor = uColor; |
6368 return (b >> (8 - 5)) | | 6368 return (b >> (8 - 5)) | |
6369 0x7E0 & (g << (6 + 5 - 8)) | | 6369 0x7E0 & (g << (6 + 5 - 8)) | |
6370 0xF800 & (r << (6 + 5 + 5 - 8)); | 6370 0xF800 & (r << (6 + 5 + 5 - 8)); |
6371 } | 6371 } |
6372 | 6372 |
6373 void Render::DrawTextureNew(float u, float v, Texture *a4) | 6373 void Render::DrawTextureNew(float u, float v, Texture_MM7 *a4) |
6374 { | 6374 { |
6375 __debugbreak(); | 6375 __debugbreak(); |
6376 } | 6376 } |
6377 | 6377 |
6378 | 6378 |
6379 void Render::DrawTextureNew(float u, float v, Image *bmp) | 6379 |
6380 | |
6381 void Render::DrawTextureCustomHeight(float u, float v, class Image *img, int custom_height) | |
6380 { | 6382 { |
6381 unsigned __int16 *v6; // esi@3 | 6383 unsigned __int16 *v6; // esi@3 |
6382 unsigned int v8; // eax@5 | 6384 unsigned int v8; // eax@5 |
6383 unsigned int v11; // eax@7 | 6385 unsigned int v11; // eax@7 |
6384 unsigned int v12; // ebx@8 | 6386 unsigned int v12; // ebx@8 |
6385 unsigned int v15; // eax@14 | 6387 unsigned int v15; // eax@14 |
6386 int v19; // [sp+10h] [bp-8h]@3 | 6388 int v19; // [sp+10h] [bp-8h]@3 |
6387 | 6389 |
6388 if (!bmp) | 6390 if (!img) |
6389 return; | 6391 return; |
6390 | 6392 |
6391 unsigned int uOutX = 640 * u; | 6393 unsigned int uOutX = 640 * u; |
6392 unsigned int uOutY = 480 * v; | 6394 unsigned int uOutY = 480 * v; |
6393 | 6395 |
6394 int width = bmp->GetWidth(); | 6396 int width = img->GetWidth(); |
6395 int height = bmp->GetHeight(); | 6397 int height = min(img->GetHeight(), custom_height); |
6396 v6 = (unsigned __int16 *)bmp->GetPixels(IMAGE_FORMAT_R5G6B5); | 6398 v6 = (unsigned __int16 *)img->GetPixels(IMAGE_FORMAT_R5G6B5); |
6397 | 6399 |
6398 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; | 6400 //v5 = &this->pTargetSurface[uOutX + uOutY * this->uTargetSurfacePitch]; |
6399 v19 = width; | 6401 v19 = width; |
6400 if (this->bClip) | 6402 if (this->bClip) |
6403 { | |
6404 if ((signed int)uOutX < (signed int)this->uClipX) | |
6401 { | 6405 { |
6402 if ((signed int)uOutX < (signed int)this->uClipX) | 6406 v8 = this->uClipX - uOutX; |
6403 { | 6407 unsigned int v9 = uOutX - this->uClipX; |
6404 v8 = this->uClipX - uOutX; | 6408 v8 *= 2; |
6405 unsigned int v9 = uOutX - this->uClipX; | 6409 width += v9; |
6406 v8 *= 2; | 6410 v6 = (unsigned __int16 *)((char *)v6 + v8); |
6407 width += v9; | 6411 //v5 = (unsigned __int16 *)((char *)v5 + v8); |
6408 v6 = (unsigned __int16 *)((char *)v6 + v8); | |
6409 //v5 = (unsigned __int16 *)((char *)v5 + v8); | |
6410 } | |
6411 if ((signed int)uOutY < (signed int)this->uClipY) | |
6412 { | |
6413 v11 = this->uClipY - uOutY; | |
6414 v6 += v19 * v11; | |
6415 height += uOutY - this->uClipY; | |
6416 //v5 += this->uTargetSurfacePitch * v11; | |
6417 } | |
6418 v12 = max(this->uClipX, uOutX); | |
6419 if ((signed int)(width + v12) >(signed int)this->uClipZ) | |
6420 { | |
6421 width = this->uClipZ - max(this->uClipX, uOutX); | |
6422 } | |
6423 v15 = max(this->uClipY, uOutY); | |
6424 if ((signed int)(v15 + height) > (signed int)this->uClipW) | |
6425 { | |
6426 height = this->uClipW - max(this->uClipY, uOutY); | |
6427 } | |
6428 } | 6412 } |
6429 | 6413 if ((signed int)uOutY < (signed int)this->uClipY) |
6430 for (int y = 0; y < height; y++) | |
6431 { | 6414 { |
6432 for (int x = 0; x < width; x++) | 6415 v11 = this->uClipY - uOutY; |
6433 { | 6416 v6 += v19 * v11; |
6434 WritePixel16(uOutX + x, uOutY + y, *v6); | 6417 height += uOutY - this->uClipY; |
6435 //*v5 = *v6; | 6418 //v5 += this->uTargetSurfacePitch * v11; |
6436 //++v5; | |
6437 ++v6; | |
6438 } | |
6439 v6 += v19 - width; | |
6440 //v5 += this->uTargetSurfacePitch - v4; | |
6441 } | 6419 } |
6420 v12 = max(this->uClipX, uOutX); | |
6421 if ((signed int)(width + v12) >(signed int)this->uClipZ) | |
6422 { | |
6423 width = this->uClipZ - max(this->uClipX, uOutX); | |
6424 } | |
6425 v15 = max(this->uClipY, uOutY); | |
6426 if ((signed int)(v15 + height) > (signed int)this->uClipW) | |
6427 { | |
6428 height = this->uClipW - max(this->uClipY, uOutY); | |
6429 } | |
6430 } | |
6431 | |
6432 for (int y = 0; y < height; y++) | |
6433 { | |
6434 for (int x = 0; x < width; x++) | |
6435 { | |
6436 WritePixel16(uOutX + x, uOutY + y, *v6); | |
6437 //*v5 = *v6; | |
6438 //++v5; | |
6439 ++v6; | |
6440 } | |
6441 v6 += v19 - width; | |
6442 //v5 += this->uTargetSurfacePitch - v4; | |
6443 } | |
6444 } | |
6445 | |
6446 void Render::DrawTextureNew(float u, float v, Image *bmp) | |
6447 { | |
6448 DrawTextureCustomHeight(u, v, bmp, bmp->GetHeight()); | |
6442 } | 6449 } |
6443 | 6450 |
6444 | 6451 |
6445 //----- (004A5D33) -------------------------------------------------------- | 6452 //----- (004A5D33) -------------------------------------------------------- |
6446 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) | 6453 void Render::CreditsTextureScroll(unsigned int pX, unsigned int pY, int move_X, int move_Y, RGBTexture *pTexture) |
6513 } | 6520 } |
6514 } | 6521 } |
6515 } | 6522 } |
6516 | 6523 |
6517 //----- (004A6E7E) -------------------------------------------------------- | 6524 //----- (004A6E7E) -------------------------------------------------------- |
6518 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) | 6525 void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture_MM7 *a4) |
6519 { | 6526 { |
6520 int v5; // edx@4 | 6527 int v5; // edx@4 |
6521 unsigned int v6; // edi@4 | 6528 unsigned int v6; // edi@4 |
6522 unsigned int v7; // edx@5 | 6529 unsigned int v7; // edx@5 |
6523 unsigned int v8; // edx@6 | 6530 unsigned int v8; // edx@6 |
6788 //v23 = uOutXa-- == 1; | 6795 //v23 = uOutXa-- == 1; |
6789 //v11 += this->uTargetSurfacePitch - v9; | 6796 //v11 += this->uTargetSurfacePitch - v9; |
6790 } | 6797 } |
6791 } | 6798 } |
6792 | 6799 |
6800 /* | |
6793 //----- (004A6A68) -------------------------------------------------------- | 6801 //----- (004A6A68) -------------------------------------------------------- |
6794 void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) | 6802 void Render::DrawTextureCustomHeight(unsigned int x, unsigned int y, Texture_MM7 *texture, __int16 height) |
6795 { | 6803 { |
6796 Texture tex; // [sp+Ch] [bp-48h]@1 | 6804 Texture_MM7 tex; // [sp+Ch] [bp-48h]@1 |
6797 | 6805 |
6798 memcpy(&tex, a4, sizeof(tex)); | 6806 memcpy(&tex, texture, sizeof(tex)); |
6799 tex.uTextureHeight = a4->uTextureHeight - height; | 6807 tex.uTextureHeight = texture->uTextureHeight - height; |
6800 if ( (signed __int16)tex.uTextureHeight > 0 ) | 6808 if ( (signed __int16)tex.uTextureHeight > 0 ) |
6801 DrawTextureTransparentColorKey(a2, a3, &tex); | 6809 DrawTextureTransparentColorKey(x, y, &tex); |
6802 } | 6810 }*/ |
6803 | 6811 |
6804 //----- (004A6AB1) -------------------------------------------------------- | 6812 //----- (004A6AB1) -------------------------------------------------------- |
6805 void Render::DrawTextAlpha( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, bool present_time_transparency ) | 6813 void Render::DrawTextAlpha( int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, bool present_time_transparency ) |
6806 { | 6814 { |
6807 int v8; // edi@2 | 6815 int v8; // edi@2 |
6961 }*/ | 6969 }*/ |
6962 } | 6970 } |
6963 } | 6971 } |
6964 | 6972 |
6965 //----- (004A68EF) -------------------------------------------------------- | 6973 //----- (004A68EF) -------------------------------------------------------- |
6966 void Render::DrawTransparentGreenShade(signed int a2, signed int a3, Texture *pTexture) | 6974 void Render::DrawTransparentGreenShade(float u, float v, Image *pTexture) |
6967 { | 6975 { |
6968 DrawMasked(a2, a3, pTexture, 0x07E0); | 6976 DrawMasked(u, v, pTexture, 0x07E0); |
6969 } | 6977 } |
6970 | 6978 |
6971 | 6979 |
6972 //----- (004A6776) -------------------------------------------------------- | 6980 //----- (004A6776) -------------------------------------------------------- |
6973 void Render::DrawTransparentRedShade(unsigned int a2, unsigned int a3, Texture *a4) | 6981 void Render::DrawTransparentRedShade(float u, float v, Image *a4) |
6974 { | 6982 { |
6975 DrawMasked(a2, a3, a4, 0xF800); | 6983 DrawMasked(u, v, a4, 0xF800); |
6976 /*Texture *v4; // edi@2 | |
6977 unsigned int v5; // ebx@4 | |
6978 unsigned __int16 *v6; // eax@4 | |
6979 unsigned int v7; // edx@5 | |
6980 unsigned int v8; // edx@6 | |
6981 unsigned int v9; // edx@7 | |
6982 unsigned int v10; // edx@8 | |
6983 unsigned int v11; // edx@9 | |
6984 unsigned int v12; // esi@12 | |
6985 unsigned int v13; // esi@15 | |
6986 unsigned int v14; // edx@17 | |
6987 unsigned int v15; // esi@18 | |
6988 unsigned __int8 *v16; // ebx@22 | |
6989 char v17; // zf@28 | |
6990 int v18; // [sp+10h] [bp-10h]@4 | |
6991 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | |
6992 int v20; // [sp+1Ch] [bp-4h]@4 | |
6993 int a2a; // [sp+28h] [bp+8h]@24 | |
6994 unsigned int a3a; // [sp+2Ch] [bp+Ch]@22 | |
6995 unsigned int a4a; // [sp+30h] [bp+10h]@11 | |
6996 | |
6997 if ( this->uNumSceneBegins ) | |
6998 { | |
6999 v4 = a4; | |
7000 if ( a4 ) | |
7001 { | |
7002 if ( a4->pPalette16 ) | |
7003 { | |
7004 v5 = a4->uTextureHeight; | |
7005 v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | |
7006 v19 = a4->pLevelOfDetail0_prolly_alpha_mask; | |
7007 v20 = a4->uTextureWidth; | |
7008 v18 = a4->uTextureWidth; | |
7009 if ( this->bClip ) | |
7010 { | |
7011 v7 = this->uClipX; | |
7012 if ( (signed int)a2 < (signed int)v7 ) | |
7013 { | |
7014 v8 = v7 - a2; | |
7015 v19 += v8; | |
7016 v20 += a2 - this->uClipX; | |
7017 v6 += v8; | |
7018 } | |
7019 v9 = this->uClipY; | |
7020 v5 = a4->uTextureHeight; | |
7021 if ( (signed int)a3 < (signed int)v9 ) | |
7022 { | |
7023 v10 = v9 - a3; | |
7024 v19 += v18 * v10; | |
7025 v5 = a3 - this->uClipY + a4->uTextureHeight; | |
7026 v4 = a4; | |
7027 v6 += this->uTargetSurfacePitch * v10; | |
7028 } | |
7029 v11 = this->uClipX; | |
7030 if ( (signed int)v11 < (signed int)a2 ) | |
7031 v11 = a2; | |
7032 a4a = this->uClipZ; | |
7033 if ( (signed int)(v11 + v20) > (signed int)a4a ) | |
7034 { | |
7035 v12 = this->uClipX; | |
7036 if ( (signed int)v12 < (signed int)a2 ) | |
7037 v12 = a2; | |
7038 v20 = a4a - v12; | |
7039 } | |
7040 v13 = this->uClipY; | |
7041 if ( (signed int)v13 < (signed int)a3 ) | |
7042 v13 = a3; | |
7043 v14 = this->uClipW; | |
7044 if ( (signed int)(v5 + v13) > (signed int)v14 ) | |
7045 { | |
7046 v15 = this->uClipY; | |
7047 if ( (signed int)v15 < (signed int)a3 ) | |
7048 v15 = a3; | |
7049 v5 = v14 - v15; | |
7050 } | |
7051 } | |
7052 if ( (signed int)v5 > 0 ) | |
7053 { | |
7054 a3a = v5; | |
7055 v16 = v19; | |
7056 do | |
7057 { | |
7058 if ( v20 > 0 ) | |
7059 { | |
7060 a2a = v20; | |
7061 do | |
7062 { | |
7063 if ( *v16 ) | |
7064 *v6 = this->uTargetRMask & v4->pPalette16[*v16]; | |
7065 ++v6; | |
7066 ++v16; | |
7067 --a2a; | |
7068 } | |
7069 while ( a2a ); | |
7070 } | |
7071 v16 += v18 - v20; | |
7072 v17 = a3a-- == 1; | |
7073 v6 += this->uTargetSurfacePitch - v20; | |
7074 } | |
7075 while ( !v17 ); | |
7076 } | |
7077 } | |
7078 } | |
7079 }*/ | |
7080 } | 6984 } |
7081 | 6985 |
7082 //----- (004A68EF) -------------------------------------------------------- | 6986 //----- (004A68EF) -------------------------------------------------------- |
7083 void Render::DrawMasked(signed int a2, signed int a3, Texture *pTexture, unsigned __int16 mask) | 6987 void Render::DrawMasked(float u, float v, Image *pTexture, unsigned __int16 mask) |
7084 { | 6988 { |
7085 unsigned int v5; // ebx@4 | 6989 unsigned int v5; // ebx@4 |
7086 int v10; // edx@8 | 6990 int v10; // edx@8 |
7087 signed int v11; // edx@9 | 6991 signed int v11; // edx@9 |
7088 signed int v12; // esi@12 | 6992 signed int v12; // esi@12 |
7089 signed int v13; // esi@15 | 6993 signed int v13; // esi@15 |
7090 signed int v15; // esi@18 | 6994 signed int v15; // esi@18 |
7091 unsigned __int8 *v16; // ebx@22 | 6995 //unsigned __int8 *v16; // ebx@22 |
7092 int v18; // [sp+10h] [bp-10h]@4 | 6996 int v18; // [sp+10h] [bp-10h]@4 |
7093 unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 | 6997 //unsigned __int8 *v19; // [sp+18h] [bp-8h]@4 |
7094 int v20; // [sp+1Ch] [bp-4h]@4 | 6998 int v20; // [sp+1Ch] [bp-4h]@4 |
7095 | 6999 |
7096 if (!uNumSceneBegins || !pTexture) | 7000 if (!uNumSceneBegins || !pTexture) |
7097 return; | 7001 return; |
7098 | 7002 |
7099 if ( pTexture->pPalette16 ) | 7003 //if ( pTexture->pPalette16 ) |
7100 { | 7004 { |
7101 v5 = pTexture->uTextureHeight; | 7005 v5 = pTexture->GetHeight(); |
7102 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; | 7006 //v6 = &this->pTargetSurface[a2 + a3 * this->uTargetSurfacePitch]; |
7103 v19 = pTexture->paletted_pixels; | 7007 //v19 = pTexture->paletted_pixels; |
7104 v20 = pTexture->uTextureWidth; | 7008 auto pixels = (unsigned __int32 *)pTexture->GetPixels(IMAGE_FORMAT_A8R8G8B8); |
7105 v18 = pTexture->uTextureWidth; | 7009 |
7010 v18 = v20 = pTexture->GetWidth(); | |
7011 | |
7012 int a2 = u * window->GetWidth(); | |
7013 int a3 = v * window->GetHeight(); | |
7014 | |
7106 int clipped_out_x = a2; | 7015 int clipped_out_x = a2; |
7107 int clipped_out_y = a3; | 7016 int clipped_out_y = a3; |
7108 if ( this->bClip ) | 7017 if ( this->bClip ) |
7109 { | 7018 { |
7110 if ( a2 < this->uClipX ) | 7019 if ( a2 < this->uClipX ) |
7111 { | 7020 { |
7112 v19 += this->uClipX - a2; | 7021 pixels += this->uClipX - a2; |
7113 v20 += a2 - this->uClipX; | 7022 v20 += a2 - this->uClipX; |
7114 clipped_out_x = uClipX; | 7023 clipped_out_x = uClipX; |
7115 } | 7024 } |
7116 v5 = pTexture->uTextureHeight; | 7025 v5 = pTexture->GetHeight(); |
7117 if ( a3 < this->uClipY ) | 7026 if ( a3 < this->uClipY ) |
7118 { | 7027 { |
7119 v10 = this->uClipY - a3; | 7028 v10 = this->uClipY - a3; |
7120 v19 += v18 * v10; | 7029 pixels += v18 * v10; |
7121 v5 = a3 - this->uClipY + pTexture->uTextureHeight; | 7030 v5 = a3 - this->uClipY + pTexture->GetHeight(); |
7122 clipped_out_y = uClipY; | 7031 clipped_out_y = uClipY; |
7123 } | 7032 } |
7124 v11 = this->uClipX; | 7033 v11 = this->uClipX; |
7125 if ( this->uClipX < a2 ) | 7034 if ( this->uClipX < a2 ) |
7126 v11 = a2; | 7035 v11 = a2; |
7141 v15 = a3; | 7050 v15 = a3; |
7142 v5 = this->uClipW - v15; | 7051 v5 = this->uClipW - v15; |
7143 } | 7052 } |
7144 } | 7053 } |
7145 | 7054 |
7146 v16 = v19; | 7055 /*v16 = v19; |
7147 for (uint y = 0; y < v5; ++y) | 7056 for (uint y = 0; y < v5; ++y) |
7148 { | 7057 { |
7149 for (int x = 0; x < v20; ++x) | 7058 for (int x = 0; x < v20; ++x) |
7150 { | 7059 { |
7151 if ( *v16 ) | 7060 if ( *v16 ) |
7152 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v16] & mask); | 7061 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v16] & mask); |
7153 ++v16; | 7062 ++v16; |
7154 } | 7063 } |
7155 v16 += v18 - v20; | 7064 v16 += v18 - v20; |
7156 } | 7065 }*/ |
7157 | 7066 |
7158 /*if ( (signed int)v5 > 0 ) | 7067 for (uint y = 0; y < v5; ++y) |
7068 { | |
7069 for (int x = 0; x < v20; ++x) | |
7159 { | 7070 { |
7160 v22 = v5; | 7071 if (*pixels & 0xFF000000) |
7161 v16 = v19; | 7072 WritePixel16( |
7162 do | 7073 clipped_out_x + x, |
7163 { | 7074 clipped_out_y + y, |
7164 if ( v20 > 0 ) | 7075 Color16((*pixels >> 16) & 0xFF, (*pixels >> 8) & 0xFF, *pixels & 0xFF) & mask |
7165 { | 7076 ); |
7166 v21 = v20; | 7077 ++pixels; |
7167 do | 7078 } |
7168 { | 7079 pixels += v18 - v20; |
7169 if ( *v16 ) | 7080 } |
7170 *v6 = this->uTargetGMask & v4->pPalette16[*v16]; | |
7171 ++v6; | |
7172 ++v16; | |
7173 --v21; | |
7174 } | |
7175 while ( v21 ); | |
7176 } | |
7177 v16 += v18 - v20; | |
7178 v17 = v22-- == 1; | |
7179 v6 += this->uTargetSurfacePitch - v20; | |
7180 } | |
7181 while ( !v17 ); | |
7182 }*/ | |
7183 } | 7081 } |
7184 } | 7082 } |
7185 | 7083 |
7186 | 7084 |
7187 //----- (004A65CC) -------------------------------------------------------- | 7085 //----- (004A65CC) -------------------------------------------------------- |
7188 void Render::_4A65CC(unsigned int x, unsigned int y, Texture *a4, Texture *a5, int a6, int a7, int a8) | 7086 void Render::_4A65CC(unsigned int x, unsigned int y, Texture_MM7 *a4, Texture_MM7 *a5, int a6, int a7, int a8) |
7189 { | 7087 { |
7190 unsigned int uHeight; // edi@6 | 7088 unsigned int uHeight; // edi@6 |
7191 unsigned int v14; // edx@11 | 7089 unsigned int v14; // edx@11 |
7192 unsigned int v16; // edx@14 | 7090 unsigned int v16; // edx@14 |
7193 unsigned int v17; // edx@17 | 7091 unsigned int v17; // edx@17 |
7289 }*/ | 7187 }*/ |
7290 } | 7188 } |
7291 } | 7189 } |
7292 | 7190 |
7293 //----- (004A63E6) -------------------------------------------------------- | 7191 //----- (004A63E6) -------------------------------------------------------- |
7294 void Render::DrawAura(unsigned int a2, unsigned int a3, Texture *a4, Texture *a5, int a6, int a7, int a8) | 7192 void Render::BlendTextures(unsigned int a2, unsigned int a3, Image *a4, Texture_MM7 *a5, int t, int start_opacity, int end_opacity) |
7193 //unsigned int a2, unsigned int a3, Image *a4, Texture_MM7 *a5, int a6, int a7, int a8) | |
7295 { | 7194 { |
7296 unsigned int v14; // edx@11 | 7195 unsigned int v14; // edx@11 |
7297 unsigned int v16; // edx@14 | 7196 unsigned int v16; // edx@14 |
7298 unsigned int v17; // edx@17 | 7197 unsigned int v17; // edx@17 |
7299 unsigned int v19; // edx@20 | 7198 unsigned int v19; // edx@20 |
7302 int Height; // [sp+10h] [bp-8h]@6 | 7201 int Height; // [sp+10h] [bp-8h]@6 |
7303 int Width; // [sp+14h] [bp-4h]@6 | 7202 int Width; // [sp+14h] [bp-4h]@6 |
7304 int v27; // [sp+24h] [bp+Ch]@23 | 7203 int v27; // [sp+24h] [bp+Ch]@23 |
7305 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 | 7204 unsigned __int8 *v28; // [sp+28h] [bp+10h]@6 |
7306 | 7205 |
7307 if ( this->uNumSceneBegins ) | 7206 /*if ( this->uNumSceneBegins ) |
7308 { | 7207 { |
7309 if ( a4 ) | 7208 if ( a4 ) |
7310 { | 7209 { |
7311 if ( a4->pPalette16 ) | 7210 if ( a4->pPalette16 ) |
7312 { | 7211 { |
7385 } | 7284 } |
7386 } | 7285 } |
7387 } | 7286 } |
7388 } | 7287 } |
7389 } | 7288 } |
7390 } | 7289 }*/ |
7391 } | 7290 } |
7392 | 7291 |
7393 | 7292 |
7394 | 7293 |
7395 | 7294 |
7458 | 7357 |
7459 for (int y = 0; y < uHeight; ++y) | 7358 for (int y = 0; y < uHeight; ++y) |
7460 { | 7359 { |
7461 for (int x = 0; x < uWidth; ++x) | 7360 for (int x = 0; x < uWidth; ++x) |
7462 { | 7361 { |
7463 //if (*v19) | |
7464 if (*pixels & 0xFF000000) | 7362 if (*pixels & 0xFF000000) |
7465 //WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | 7363 WritePixel16( |
7466 WritePixel16(clipped_out_x + x, clipped_out_y + y, Color16((*pixels >> 16) & 0xFF, (*pixels >> 8) & 0xFF, *pixels & 0xFF)); | 7364 clipped_out_x + x, |
7365 clipped_out_y + y, | |
7366 Color16( | |
7367 (*pixels >> 16) & 0xFF, | |
7368 (*pixels >> 8) & 0xFF, | |
7369 *pixels & 0xFF | |
7370 ) | |
7371 ); | |
7467 ++pixels; | 7372 ++pixels; |
7468 } | 7373 } |
7469 pixels += img->GetWidth() - uWidth; | 7374 pixels += img->GetWidth() - uWidth; |
7470 } | 7375 } |
7471 } | 7376 } |
7472 | 7377 |
7473 | 7378 |
7474 | 7379 |
7475 //----- (004A6274) -------------------------------------------------------- | 7380 //----- (004A6274) -------------------------------------------------------- |
7476 void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture *pTexture) | 7381 void Render::DrawTextureIndexedAlpha(unsigned int uX, unsigned int uY, Texture_MM7 *pTexture) |
7477 { | 7382 { |
7478 int uHeight; // ebx@4 | 7383 int uHeight; // ebx@4 |
7479 unsigned int v11; // edx@9 | 7384 unsigned int v11; // edx@9 |
7480 unsigned int v12; // esi@12 | 7385 unsigned int v12; // esi@12 |
7481 unsigned int v13; // esi@15 | 7386 unsigned int v13; // esi@15 |
7543 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); | 7448 WritePixel16(clipped_out_x + x, clipped_out_y + y, pTexture->pPalette16[*v19]); |
7544 ++v19; | 7449 ++v19; |
7545 } | 7450 } |
7546 v19 += pTexture->uTextureWidth - uWidth; | 7451 v19 += pTexture->uTextureWidth - uWidth; |
7547 } | 7452 } |
7548 /*if ( (signed int)uHeight > 0 ) | |
7549 { | |
7550 uYa = uHeight; | |
7551 v16 = v19; | |
7552 do | |
7553 { | |
7554 if ( uWidth > 0 ) | |
7555 { | |
7556 uXa = uWidth; | |
7557 do | |
7558 { | |
7559 if ( *v16 ) | |
7560 *v6 = pCurrentTexture->pPalette16[*v16]; | |
7561 ++v6; | |
7562 ++v16; | |
7563 } | |
7564 while ( uXa-- !=1 ); | |
7565 } | |
7566 v16 += v18 - uWidth; | |
7567 uFlag = uYa-- == 1; | |
7568 v6 += this->uTargetSurfacePitch - uWidth; | |
7569 } | |
7570 while ( !uFlag ); | |
7571 }*/ | |
7572 } | 7453 } |
7573 } | 7454 } |
7574 } | 7455 } |
7575 } | 7456 } |
7576 | 7457 |
7577 //----- (004A612A) -------------------------------------------------------- | 7458 //----- (004A612A) -------------------------------------------------------- |
7578 void Render::DrawMaskToZBuffer(signed int uOutX, unsigned int uOutY, Texture *pTexture, int zVal) | 7459 void Render::ZDrawTextureAlpha(float u, float v, Image *img, int zVal) |
7579 { | 7460 { |
7580 unsigned int v6; // edx@3 | 7461 unsigned int v6; // edx@3 |
7581 int v7; // ebx@3 | 7462 int v7; // ebx@3 |
7582 int v8; // edi@3 | 7463 int v8; // edi@3 |
7583 int v10; // eax@5 | 7464 int v10; // eax@5 |
7587 unsigned int v17; // ecx@17 | 7468 unsigned int v17; // ecx@17 |
7588 int v18; // edx@23 | 7469 int v18; // edx@23 |
7589 int v19; // [sp+Ch] [bp-Ch]@3 | 7470 int v19; // [sp+Ch] [bp-Ch]@3 |
7590 int v20; // [sp+10h] [bp-8h]@3 | 7471 int v20; // [sp+10h] [bp-8h]@3 |
7591 int uOutXa; // [sp+20h] [bp+8h]@21 | 7472 int uOutXa; // [sp+20h] [bp+8h]@21 |
7592 unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 | 7473 //unsigned __int8 *uOutYa; // [sp+24h] [bp+Ch]@3 |
7593 int *pZBuffer; // [sp+28h] [bp+10h]@3 | 7474 int *pZBuffer; // [sp+28h] [bp+10h]@3 |
7594 | 7475 |
7595 if ( this->uNumSceneBegins ) | 7476 if (!this->uNumSceneBegins || !img) |
7596 { | 7477 return; |
7597 if ( pTexture ) | 7478 |
7598 { | 7479 int uOutX = u * this->window->GetWidth(); |
7480 int uOutY = v * this->window->GetHeight(); | |
7481 | |
7599 v6 = uOutY; | 7482 v6 = uOutY; |
7600 v7 = pTexture->uTextureHeight; | 7483 v7 = img->GetHeight(); |
7601 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; | 7484 pZBuffer = &this->pActiveZBuffer[uOutX + window->GetWidth() * uOutY]; |
7602 uOutYa = pTexture->paletted_pixels; | 7485 //uOutYa = pTexture->paletted_pixels; |
7603 v8 = pTexture->uTextureWidth; | 7486 v8 = v20 = v19 = img->GetWidth(); |
7604 v20 = pTexture->uTextureWidth; | 7487 auto pixels = (unsigned __int32 *)img->GetPixels(IMAGE_FORMAT_A8R8G8B8); |
7605 v19 = pTexture->uTextureWidth; | |
7606 if ( this->bClip ) | 7488 if ( this->bClip ) |
7607 { | 7489 { |
7608 if ( uOutX < this->uClipX ) | 7490 if ( uOutX < this->uClipX ) |
7609 { | 7491 { |
7610 v10 = this->uClipX - uOutX; | 7492 v10 = this->uClipX - uOutX; |
7611 uOutYa += v10; | 7493 pixels += v10; |
7612 v8 += uOutX - this->uClipX; | 7494 v8 += uOutX - this->uClipX; |
7613 v20 = v8; | 7495 v20 = v8; |
7614 pZBuffer += v10; | 7496 pZBuffer += v10; |
7615 } | 7497 } |
7616 if ( (signed int)v6 < (signed int)this->uClipY ) | 7498 if ( (signed int)v6 < (signed int)this->uClipY ) |
7617 { | 7499 { |
7618 uOutYa += v19 * (this->uClipY - v6); | 7500 pixels += v19 * (this->uClipY - v6); |
7619 v7 += v6 - this->uClipY; | 7501 v7 += v6 - this->uClipY; |
7620 pZBuffer += window->GetWidth() * (this->uClipY - v6); | 7502 pZBuffer += window->GetWidth() * (this->uClipY - v6); |
7621 v8 = v20; | 7503 v8 = v20; |
7622 } | 7504 } |
7623 v12 = this->uClipX; | 7505 v12 = this->uClipX; |
7639 if ( (signed int)this->uClipY >= (signed int)v6 ) | 7521 if ( (signed int)this->uClipY >= (signed int)v6 ) |
7640 v6 = v17; | 7522 v6 = v17; |
7641 v7 = this->uClipW - v6; | 7523 v7 = this->uClipW - v6; |
7642 } | 7524 } |
7643 } | 7525 } |
7526 | |
7527 | |
7528 | |
7644 if ( v7 > 0 ) | 7529 if ( v7 > 0 ) |
7645 { | 7530 { |
7646 uOutXa = v7; | 7531 uOutXa = v7; |
7647 do | 7532 do |
7648 { | 7533 { |
7649 if ( v8 > 0 ) | 7534 if ( v8 > 0 ) |
7650 { | 7535 { |
7651 v18 = v8; | 7536 v18 = v8; |
7652 do | 7537 do |
7653 { | 7538 { |
7654 if ( *uOutYa ) | 7539 if ( *pixels & 0xFF000000) |
7655 *pZBuffer = zVal; | 7540 *pZBuffer = zVal; |
7656 ++pZBuffer; | 7541 ++pZBuffer; |
7657 ++uOutYa; | 7542 ++pixels; |
7658 --v18; | 7543 --v18; |
7659 } | 7544 } |
7660 while ( v18 ); | 7545 while ( v18 ); |
7661 } | 7546 } |
7662 pZBuffer += window->GetWidth() - v8; | 7547 pZBuffer += window->GetWidth() - v8; |
7663 uOutYa += v19 - v8; | 7548 pixels += v19 - v8; |
7664 --uOutXa; | 7549 --uOutXa; |
7665 } | 7550 } |
7666 while ( uOutXa ); | 7551 while ( uOutXa ); |
7667 } | 7552 } |
7668 } | 7553 |
7669 } | |
7670 } | 7554 } |
7671 | 7555 |
7672 //----- (004A601E) -------------------------------------------------------- | 7556 //----- (004A601E) -------------------------------------------------------- |
7673 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Texture *pTexture, int a5) | 7557 void Render::ZBuffer_Fill_2(signed int a2, signed int a3, Image *pTexture, int a5) |
7674 { | 7558 { |
7675 signed int v5; // edx@3 | 7559 /* signed int v5; // edx@3 |
7676 int v6; // ebx@3 | 7560 int v6; // ebx@3 |
7677 int v7; // esi@3 | 7561 int v7; // esi@3 |
7678 void *v8; // esi@3 | 7562 void *v8; // esi@3 |
7679 signed int v11; // edi@8 | 7563 signed int v11; // edi@8 |
7680 signed int v13; // edi@11 | 7564 signed int v13; // edi@11 |
7737 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); | 7621 v8 = (char *)v8 + 4 * (window->GetWidth() - pTexturea); |
7738 --v6; | 7622 --v6; |
7739 } | 7623 } |
7740 while ( v6 ); | 7624 while ( v6 ); |
7741 } | 7625 } |
7742 } | 7626 }*/ |
7743 } | 7627 } |
7744 | 7628 |
7745 | 7629 |
7746 | 7630 |
7747 //----- (004A5EB2) -------------------------------------------------------- | 7631 //----- (004A5EB2) -------------------------------------------------------- |
7748 void Render::DrawTextureTransparentColorKey(signed int x, signed int y, Texture *tex) | 7632 void Render::DrawTextureTransparentColorKey(signed int x, signed int y, Texture_MM7 *tex) |
7749 { | 7633 { |
7750 int v5; // ebx@4 | 7634 int v5; // ebx@4 |
7751 unsigned int v8; // edx@6 | 7635 unsigned int v8; // edx@6 |
7752 unsigned int v10; // edx@8 | 7636 unsigned int v10; // edx@8 |
7753 unsigned int v11; // edx@9 | 7637 unsigned int v11; // edx@9 |
8304 | 8188 |
8305 //----- (0047840D) -------------------------------------------------------- | 8189 //----- (0047840D) -------------------------------------------------------- |
8306 void Render::DrawBuildingsD3D() | 8190 void Render::DrawBuildingsD3D() |
8307 { | 8191 { |
8308 int v9; // ecx@8 | 8192 int v9; // ecx@8 |
8309 Texture *pFaceTexture; // eax@10 | 8193 Texture_MM7 *pFaceTexture; // eax@10 |
8310 unsigned int v16; // edi@22 | 8194 unsigned int v16; // edi@22 |
8311 int v27; // eax@57 | 8195 int v27; // eax@57 |
8312 // int vertex_id; // eax@58 | 8196 // int vertex_id; // eax@58 |
8313 unsigned int v34; // eax@80 | 8197 unsigned int v34; // eax@80 |
8314 int v40; // [sp-4h] [bp-5Ch]@2 | 8198 int v40; // [sp-4h] [bp-5Ch]@2 |
8546 | 8430 |
8547 //if ( pParty->uCurrentHour > 20 || pParty->uCurrentHour < 5 ) | 8431 //if ( pParty->uCurrentHour > 20 || pParty->uCurrentHour < 5 ) |
8548 //pSkyPolygon.uTileBitmapID = pOutdoor->New_SKY_NIGHT_ID; | 8432 //pSkyPolygon.uTileBitmapID = pOutdoor->New_SKY_NIGHT_ID; |
8549 //else | 8433 //else |
8550 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) | 8434 pSkyPolygon.uTileBitmapID = pOutdoor->sSky_TextureID;//179(original 166) |
8551 pSkyPolygon.pTexture = (Texture *)(pSkyPolygon.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[pSkyPolygon.uTileBitmapID] : 0); | 8435 pSkyPolygon.pTexture = (Texture_MM7 *)(pSkyPolygon.uTileBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[pSkyPolygon.uTileBitmapID] : 0); |
8552 if ( pSkyPolygon.pTexture ) | 8436 if ( pSkyPolygon.pTexture ) |
8553 { | 8437 { |
8554 pSkyPolygon.dimming_level = 0; | 8438 pSkyPolygon.dimming_level = 0; |
8555 pSkyPolygon.uNumVertices = 4; | 8439 pSkyPolygon.uNumVertices = 4; |
8556 //centering(центруем)----------------------------------------------------------------- | 8440 //centering(центруем)----------------------------------------------------------------- |