Mercurial > mm7
changeset 737:225d92620998
004A19D8 refactored
author | Nomad |
---|---|
date | Fri, 22 Mar 2013 20:40:23 +0200 |
parents | 9cc972ebd3cf |
children | 852ec78d9548 |
files | LOD.cpp Render.cpp mm7_4.cpp mm7_data.h |
diffstat | 4 files changed, 30 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/LOD.cpp Fri Mar 22 20:07:55 2013 +0200 +++ b/LOD.cpp Fri Mar 22 20:40:23 2013 +0200 @@ -2160,19 +2160,19 @@ int LODFile_Sprites::_461397() { int result; // eax@1 - int *pfield_ECA0; // edi@1 + //int *pfield_ECA0; // edi@1 int v3; // esi@1 int v4; // ecx@3 result = this->uNumLoadedSprites; - pfield_ECA0 = &this->field_ECA0; + //pfield_ECA0 = &this->field_ECA0; v3 = this->field_ECA0; this->field_ECA8 = result; if ( result < v3 ) this->field_ECA8 = v3; v4 = this->field_ECA4; if ( v3 < v4 ) - *pfield_ECA0 = v4; + field_ECA0 = v4; return result; } @@ -3051,12 +3051,9 @@ Texture *LODFile_IconsBitmaps::LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType) { uint id = LoadTexture(pContainer, uTextureType); - if (id == -1) - { - assert(false); - Log::Warning(L"LOD error\\no container: \"%S\"", pContainer); - return nullptr; - } + + assert(id != -1 && L"Texture not found"); + return &pTextures[id]; }
--- a/Render.cpp Fri Mar 22 20:07:55 2013 +0200 +++ b/Render.cpp Fri Mar 22 20:40:23 2013 +0200 @@ -8140,7 +8140,7 @@ if ( pSoftBillboard->uTintColor && this->bTinting ) { v11 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); - v12 = sub_4A19D8(pSoftBillboard->uTintColor, v11); + v12 = BlendColors(pSoftBillboard->uTintColor, v11); if ( v28 ) v12 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v12 >> 1); } @@ -8586,7 +8586,7 @@ unsigned int diffuse = ::GetActorTintColor(dimming_level, 0, a2->zbuffer_depth, 0, pBillboard); if (a2->uTintColor & 0x00FFFFFF && bTinting) { - diffuse = sub_4A19D8(a2->uTintColor, diffuse); + diffuse = BlendColors(a2->uTintColor, diffuse); if (a2->uTintColor & 0xFF000000) diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); }
--- a/mm7_4.cpp Fri Mar 22 20:07:55 2013 +0200 +++ b/mm7_4.cpp Fri Mar 22 20:40:23 2013 +0200 @@ -4932,9 +4932,9 @@ //----- (004A19D8) -------------------------------------------------------- -int __fastcall sub_4A19D8(unsigned int a1, unsigned int a2) +unsigned int BlendColors(unsigned int a1, unsigned int a2) { - signed __int64 v2; // ST10_8@1 + /*signed __int64 v2; // ST10_8@1 double v3; // st7@1 float v4; // ST24_4@1 double v5; // ST10_8@1 @@ -4945,22 +4945,32 @@ float v10; // ST24_4@1 double v11; // ST10_8@1 float v12; // ST24_4@1 - double v13; // ST08_8@1 - - v2 = a1 >> 24; - v3 = (double)v2 * 0.0039215689; + double v13; // ST08_8@1*/ + + uint alpha = (uint)floorf(0.5f + (a1 >> 24) / 255.0f * + (a2 >> 24) / 255.0f * 255.0f), + red = (uint)floorf(0.5f + ((a1 >> 16) & 0xFF) / 255.0f * + ((a2 >> 16) & 0xFF) / 255.0f * 255.0f), + green = (uint)floorf(0.5f + ((a1 >> 8) & 0xFF) / 255.0f * + ((a2 >> 8) & 0xFF) / 255.0f * 255.0f), + blue = (uint)floorf(0.5f + ((a1 >> 0) & 0xFF) / 255.0f * + ((a2 >> 0) & 0xFF) / 255.0f * 255.0f); + return (alpha << 24) | (red << 16) | (green << 8) | blue; + /*v2 = a1 >> 24; + v3 = (double)v2 / 255.0f; + HIDWORD(v2) = 0; LODWORD(v2) = a2 >> 24; - v4 = v3 * (double)v2 * 0.0039215689 * 255.0; + v4 = v3 * (double)v2 / 255.0f * 255.0; v5 = v4 + 6.7553994e15; v6 = LODWORD(v5); - v7 = (double)((a1 >> 16) & 0xFFi64) * 0.0039215689 * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; + v7 = (double)((a1 >> 16) & 0xFFi64) / 255.0f * (double)((a2 >> 16) & 0xFF) * 0.0039215689 * 255.0; v8 = v7 + 6.7553994e15; v9 = LOBYTE(v8); - v10 = (double)((unsigned __int16)a1 >> 8) * 0.0039215689 * (double)((unsigned __int16)a2 >> 8) * 0.0039215689 * 255.0; + v10 = (double)((unsigned __int16)a1 >> 8) / 255.0f * (double)((unsigned __int16)a2 >> 8) / 255.0f * 255.0; v11 = v10 + 6.7553994e15; - v12 = (double)(a1 & 0xFFi64) * 0.0039215689 * (double)(unsigned __int8)a2 * 0.0039215689 * 255.0; + v12 = (double)(a1 & 0xFFi64) / 255.0f * (double)(unsigned __int8)a2 / 255.0f * 255.0; v13 = v12 + 6.7553994e15; - return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8); + return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);*/ }
--- a/mm7_data.h Fri Mar 22 20:07:55 2013 +0200 +++ b/mm7_data.h Fri Mar 22 20:40:23 2013 +0200 @@ -2254,7 +2254,7 @@ unsigned int __fastcall GetMaxMipLevels(unsigned int uDim); bool __cdecl CheckTextureStages(); bool __cdecl AreRenderSurfacesOk(); -int __fastcall sub_4A19D8(unsigned int, unsigned int); // weak +unsigned int BlendColors(unsigned int c1, unsigned int c2); // weak void __cdecl DoRenderBillboards_D3D(); int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int z, int a4, unsigned int lightColor); void __cdecl Present_ColorKey();