Mercurial > might-and-magic-trilogy
comparison Render.cpp @ 68:fdacbc653945
BLV render: first image
author | Nomad |
---|---|
date | Sat, 27 Oct 2012 19:23:06 +0200 |
parents | 5159d2e6f559 |
children | 75994455e457 |
comparison
equal
deleted
inserted
replaced
63:427b6c3b4e0f | 68:fdacbc653945 |
---|---|
4127 | 4127 |
4128 | 4128 |
4129 //----- (0049E4FC) -------------------------------------------------------- | 4129 //----- (0049E4FC) -------------------------------------------------------- |
4130 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) | 4130 void RenderD3D::ClearTarget(unsigned int bClearColor, unsigned int uClearColor, unsigned int bClearDepth, float z_clear) |
4131 { | 4131 { |
4132 unsigned int flags; // esi@1 | 4132 uint uClearFlags = 0; |
4133 IDirect3DViewport3 *v6; // eax@6 | 4133 |
4134 D3DRECT v7; // [sp+Ch] [bp-10h]@6 | 4134 if (bClearColor) |
4135 | 4135 uClearFlags |= D3DCLEAR_TARGET; |
4136 flags = 0; | 4136 if (bClearDepth) |
4137 if ( bClearColor ) | 4137 uClearFlags |= D3DCLEAR_ZBUFFER; |
4138 flags = 1; // D3DRMCLEAR_TARGET | 4138 |
4139 if ( bClearDepth ) | 4139 D3DRECT rects[] = {{0, 0, 640, 480}}; |
4140 flags |= 2u; // D3DRMCLEAR_ZBUFFER | 4140 if (uClearFlags) |
4141 if ( flags ) | 4141 pViewport->Clear2(1, rects, uClearFlags, uClearColor, z_clear, 0); |
4142 { | |
4143 v6 = this->pViewport; | |
4144 v7.x1 = 0; | |
4145 v7.y1 = 0; | |
4146 v7.x2 = 640; | |
4147 v7.y2 = 480; // BUG | |
4148 v6->Clear2( | |
4149 1, | |
4150 &v7, | |
4151 flags, | |
4152 uClearColor, | |
4153 LODWORD(z_clear), | |
4154 0); | |
4155 } | |
4156 } | 4142 } |
4157 | 4143 |
4158 | 4144 |
4159 //----- (0049E54D) -------------------------------------------------------- | 4145 //----- (0049E54D) -------------------------------------------------------- |
4160 void RenderD3D::Present(bool bForceBlit) | 4146 void RenderD3D::Present(bool bForceBlit) |
4161 { | 4147 { |
4162 RenderD3D *v2; // esi@1 | |
4163 char bFullscreen; // zf@1 | |
4164 struct tagRECT Rect; // [sp+8h] [bp-28h]@4 | |
4165 RECT v5; // [sp+18h] [bp-18h]@1 | 4148 RECT v5; // [sp+18h] [bp-18h]@1 |
4166 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 | 4149 struct tagPOINT Point; // [sp+28h] [bp-8h]@4 |
4167 | 4150 |
4168 v2 = this; | |
4169 v5.left = 0; | 4151 v5.left = 0; |
4170 v5.top = 0; | 4152 v5.top = 0; |
4171 bFullscreen = this->bWindowed == 0; | |
4172 v5.bottom = 480; | 4153 v5.bottom = 480; |
4173 v5.right = 640; | 4154 v5.right = 640; |
4174 if ( !bFullscreen || bForceBlit ) | 4155 |
4175 { | 4156 if (bWindowed || bForceBlit) |
4176 GetClientRect(this->hWindow, &Rect); | 4157 { |
4158 RECT rc; | |
4159 GetClientRect(hWindow, &rc); | |
4177 Point.y = 0; | 4160 Point.y = 0; |
4178 Point.x = 0; | 4161 Point.x = 0; |
4179 ClientToScreen(v2->hWindow, &Point); | 4162 ClientToScreen(hWindow, &Point); |
4180 OffsetRect(&Rect, Point.x, Point.y); | 4163 OffsetRect(&rc, Point.x, Point.y); |
4181 v2->pFrontBuffer->Blt(&Rect, v2->pBackBuffer, &v5, DDBLT_WAIT, 0); | 4164 pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0); |
4182 } | 4165 } |
4183 else | 4166 else |
4184 { | 4167 pFrontBuffer->Flip(0, 1); |
4185 this->pFrontBuffer->Flip(0, 1u); | |
4186 } | |
4187 } | 4168 } |
4188 | 4169 |
4189 | 4170 |
4190 //----- (0049E5D4) -------------------------------------------------------- | 4171 //----- (0049E5D4) -------------------------------------------------------- |
4191 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) | 4172 bool RenderD3D::CreateTexture(unsigned int uTextureWidth, unsigned int uTextureHeight, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture, bool bAlphaChannel, bool bMipmaps, unsigned int uMinDeviceTexDim) |
4690 | 4671 |
4691 | 4672 |
4692 //----- (0049ECC4) -------------------------------------------------------- | 4673 //----- (0049ECC4) -------------------------------------------------------- |
4693 void Render::ClearBlack() | 4674 void Render::ClearBlack() |
4694 { | 4675 { |
4695 Render *v1; // eax@1 | 4676 if (pRenderD3D) |
4696 RenderD3D *v2; // ecx@1 | 4677 { |
4697 | 4678 if (field_40110) |
4698 v1 = this; | 4679 pRenderD3D->ClearTarget(true, 0, false, 0.0); |
4699 v2 = this->pRenderD3D; | |
4700 if ( v2 ) | |
4701 { | |
4702 if ( v1->field_40110 ) | |
4703 pRenderD3D->ClearTarget(1u, 0, 0, 0.0); | |
4704 } | 4680 } |
4705 else | 4681 else |
4706 { | 4682 memset(pRenderer->pTargetSurface, 0, 4 * (field_10 * field_14 / 2)); |
4707 memset(pRenderer->pTargetSurface, 0, 4 * (v1->field_10 * v1->field_14 >> 1)); | |
4708 } | |
4709 } | 4683 } |
4710 | 4684 |
4711 | 4685 |
4712 //----- (0049ED18) -------------------------------------------------------- | 4686 //----- (0049ED18) -------------------------------------------------------- |
4713 void Render::PresentBlackScreen() | 4687 void Render::PresentBlackScreen() |
4716 IDirectDrawSurface *v2; // eax@3 | 4690 IDirectDrawSurface *v2; // eax@3 |
4717 DDBLTFX v3; // [sp+4h] [bp-74h]@5 | 4691 DDBLTFX v3; // [sp+4h] [bp-74h]@5 |
4718 RECT x; // [sp+68h] [bp-10h]@3 | 4692 RECT x; // [sp+68h] [bp-10h]@3 |
4719 | 4693 |
4720 memset(&v3, 0, sizeof(DDBLTFX)); | 4694 memset(&v3, 0, sizeof(DDBLTFX)); |
4721 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) | 4695 if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || |
4696 pVersion->pVersionInfo.dwMajorVersion >= 5) | |
4722 { | 4697 { |
4723 x.left = uWindowX; | 4698 x.left = uWindowX; |
4724 x.right = uWindowX + uWindowHeight; | 4699 x.right = uWindowX + uWindowHeight; |
4725 x.top = uWindowY; | 4700 x.top = uWindowY; |
4726 w = uWindowY + uWindowWidth; | 4701 w = uWindowY + uWindowWidth; |
5433 | 5408 |
5434 | 5409 |
5435 //----- (0049FBCD) -------------------------------------------------------- | 5410 //----- (0049FBCD) -------------------------------------------------------- |
5436 void Render::ClearTarget(unsigned int uColor) | 5411 void Render::ClearTarget(unsigned int uColor) |
5437 { | 5412 { |
5438 Render *v2; // eax@1 | 5413 if (pRenderD3D) |
5439 RenderD3D *v3; // ecx@1 | 5414 { |
5440 | 5415 if (field_40110) |
5441 v2 = this; | 5416 pRenderD3D->ClearTarget(true, uColor, false, 0.0); |
5442 v3 = this->pRenderD3D; | |
5443 if ( v3 ) | |
5444 { | |
5445 if ( v2->field_40110 ) | |
5446 pRenderD3D->ClearTarget(1u, uColor, 0, 0.0); | |
5447 } | 5417 } |
5448 else | 5418 else |
5449 { | 5419 memset32(pTargetSurface, uColor, field_10 * field_14 / 2); |
5450 memset32(v2->pTargetSurface, uColor, v2->field_10 * v2->field_14 >> 1); | |
5451 } | |
5452 } | 5420 } |
5453 | 5421 |
5454 | 5422 |
5455 | 5423 |
5456 //----- (0049FC23) -------------------------------------------------------- | 5424 //----- (0049FC23) -------------------------------------------------------- |
5477 { | 5445 { |
5478 if ( v1->field_40110 ) | 5446 if ( v1->field_40110 ) |
5479 { | 5447 { |
5480 if (pAsyncMouse) | 5448 if (pAsyncMouse) |
5481 pAsyncMouse->_46BAEC(); | 5449 pAsyncMouse->_46BAEC(); |
5482 pRenderD3D->Present(0); | 5450 pRenderD3D->Present(false); |
5483 if (pAsyncMouse) | 5451 if (pAsyncMouse) |
5484 pAsyncMouse->_46BB0A(); | 5452 pAsyncMouse->_46BB0A(); |
5485 } | 5453 } |
5486 } | 5454 } |
5487 else | 5455 else |
7111 { | 7079 { |
7112 if (!uNumD3DSceneBegins++) | 7080 if (!uNumD3DSceneBegins++) |
7113 { | 7081 { |
7114 if (pRenderD3D) | 7082 if (pRenderD3D) |
7115 { | 7083 { |
7116 pRenderD3D->ClearTarget(1u, 0, 1u, 1.0); | 7084 pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); |
7117 pRenderer->uNumBillboardsToDraw = 0; | 7085 pRenderer->uNumBillboardsToDraw = 0; |
7118 pRenderD3D->pDevice->BeginScene(); | 7086 pRenderD3D->pDevice->BeginScene(); |
7119 if ( !pRenderD3D->DoesRaiseExceptions() ) | 7087 if (!pRenderD3D->DoesRaiseExceptions()) |
7120 { | 7088 { |
7121 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); | 7089 MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); |
7122 } | 7090 } |
7123 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) | 7091 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) |
7124 uFogColor = GetLevelFogColor(); | 7092 uFogColor = GetLevelFogColor(); |
7125 else | 7093 else |
7126 uFogColor = 0; | 7094 uFogColor = 0; |
7321 } | 7289 } |
7322 } | 7290 } |
7323 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); | 7291 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); |
7324 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7292 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7325 D3DPT_TRIANGLEFAN, | 7293 D3DPT_TRIANGLEFAN, |
7326 452, | 7294 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7327 arary_77E5C8, | 7295 arary_77E5C8, |
7328 uNumVertices, | 7296 uNumVertices, |
7329 16)); | 7297 16)); |
7330 if ( a6 ) | 7298 if ( a6 ) |
7331 { | 7299 { |
7381 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); | 7349 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); |
7382 | 7350 |
7383 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | 7351 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
7384 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7352 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7385 D3DPT_TRIANGLEFAN, | 7353 D3DPT_TRIANGLEFAN, |
7386 452, | 7354 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7387 arary_77E5C8, | 7355 arary_77E5C8, |
7388 uNumVertices, | 7356 uNumVertices, |
7389 16)); | 7357 16)); |
7390 //v63 = (const char *)v7->pRenderD3D->pDevice; | 7358 //v63 = (const char *)v7->pRenderD3D->pDevice; |
7391 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); | 7359 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); |
7412 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); | 7380 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); |
7413 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1u)); | 7381 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1u)); |
7414 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3u)); | 7382 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3u)); |
7415 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7383 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7416 D3DPT_TRIANGLEFAN, | 7384 D3DPT_TRIANGLEFAN, |
7417 452, | 7385 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7418 arary_77E5C8, | 7386 arary_77E5C8, |
7419 uNumVertices, | 7387 uNumVertices, |
7420 16)); | 7388 16)); |
7421 if ( pRenderer->bUsingSpecular ) | 7389 if ( pRenderer->bUsingSpecular ) |
7422 { | 7390 { |
7439 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); | 7407 ErrD3D(pRenderD3D->pDevice->SetTexture(0, 0)); |
7440 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6u)); | 7408 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 6u)); |
7441 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5u)); | 7409 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 5u)); |
7442 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7410 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7443 D3DPT_TRIANGLEFAN, | 7411 D3DPT_TRIANGLEFAN, |
7444 452, | 7412 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7445 arary_77E5C8, | 7413 arary_77E5C8, |
7446 uNumVertices, | 7414 uNumVertices, |
7447 16)); | 7415 16)); |
7448 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1)); | 7416 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1)); |
7449 //v44 = pRenderer->pRenderD3D->pDevice; | 7417 //v44 = pRenderer->pRenderD3D->pDevice; |
7523 while ( v14 ); | 7491 while ( v14 ); |
7524 } | 7492 } |
7525 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a4)); | 7493 ErrD3D(pRenderD3D->pDevice->SetTexture(0, a4)); |
7526 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7494 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7527 D3DPT_TRIANGLEFAN, | 7495 D3DPT_TRIANGLEFAN, |
7528 452, | 7496 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7529 arary_77E5C8, | 7497 arary_77E5C8, |
7530 uNumVertices, | 7498 uNumVertices, |
7531 24)); | 7499 24)); |
7532 } | 7500 } |
7533 } | 7501 } |
7579 while ( v4 ); | 7547 while ( v4 ); |
7580 } | 7548 } |
7581 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | 7549 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
7582 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7550 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7583 D3DPT_TRIANGLEFAN, | 7551 D3DPT_TRIANGLEFAN, |
7584 452, | 7552 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7585 arary_77E5C8, | 7553 arary_77E5C8, |
7586 a2, | 7554 a2, |
7587 28)); | 7555 28)); |
7588 } | 7556 } |
7589 } | 7557 } |
7590 } | 7558 } |
7591 | 7559 |
7592 | 7560 |
7593 | 7561 |
7594 //----- (004A2FC0) -------------------------------------------------------- | 7562 //----- (004A2FC0) -------------------------------------------------------- |
7595 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int a6, int a7, int a8) | 7563 void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) |
7596 { | 7564 { |
7597 Render *v8; // edi@1 | 7565 //Render *v8; // edi@1 |
7598 unsigned int v9; // esi@3 | 7566 //unsigned int v9; // esi@3 |
7599 HRESULT v10; // eax@8 | |
7600 HRESULT v11; // eax@8 | |
7601 char *v12; // ecx@9 | 7567 char *v12; // ecx@9 |
7602 char *v13; // eax@9 | 7568 char *v13; // eax@9 |
7603 double v14; // st6@10 | 7569 double v14; // st6@10 |
7604 int v15; // edx@10 | 7570 int v15; // edx@10 |
7605 Texture *v16; // edx@10 | 7571 Texture *v16; // edx@10 |
7606 double v17; // st6@10 | 7572 double v17; // st6@10 |
7607 char v18; // zf@10 | 7573 //char v18; // zf@10 |
7608 Texture *v19; // edx@10 | 7574 Texture *v19; // edx@10 |
7609 HRESULT v20; // eax@11 | |
7610 HRESULT v21; // eax@11 | |
7611 HRESULT v22; // eax@11 | |
7612 Texture *v23; // edx@16 | 7575 Texture *v23; // edx@16 |
7613 char *v24; // ecx@16 | 7576 char *v24; // ecx@16 |
7614 char *v25; // eax@16 | 7577 char *v25; // eax@16 |
7615 double v26; // st6@17 | 7578 double v26; // st6@17 |
7616 int v27; // esi@17 | 7579 int v27; // esi@17 |
7617 double v28; // st6@17 | 7580 double v28; // st6@17 |
7618 HRESULT v29; // eax@18 | |
7619 HRESULT v30; // eax@18 | |
7620 HRESULT v31; // eax@18 | |
7621 HRESULT v32; // eax@18 | |
7622 unsigned int v33; // ecx@18 | 7581 unsigned int v33; // ecx@18 |
7623 char *v34; // eax@19 | 7582 char *v34; // eax@19 |
7624 HRESULT v35; // eax@21 | 7583 //Texture *v45; // edx@23 |
7625 HRESULT v36; // eax@21 | 7584 //char *v46; // ecx@23 |
7626 HRESULT v37; // eax@21 | 7585 //char *v47; // eax@23 |
7627 HRESULT v38; // eax@21 | 7586 //double v48; // st6@24 |
7628 HRESULT v39; // eax@21 | 7587 //int v49; // esi@24 |
7629 HRESULT v40; // eax@21 | 7588 //double v50; // st6@24 |
7630 HRESULT v41; // eax@21 | |
7631 HRESULT v42; // eax@21 | |
7632 HRESULT v43; // eax@21 | |
7633 HRESULT v44; // eax@21 | |
7634 Texture *v45; // edx@23 | |
7635 char *v46; // ecx@23 | |
7636 char *v47; // eax@23 | |
7637 double v48; // st6@24 | |
7638 int v49; // esi@24 | |
7639 double v50; // st6@24 | |
7640 HRESULT v51; // eax@25 | |
7641 HRESULT v52; // eax@25 | |
7642 const char *v53; // [sp-Ch] [bp-20h]@21 | 7589 const char *v53; // [sp-Ch] [bp-20h]@21 |
7643 int v54; // [sp-8h] [bp-1Ch]@21 | 7590 //int v54; // [sp-8h] [bp-1Ch]@21 |
7644 unsigned int v55; // [sp-4h] [bp-18h]@21 | 7591 //unsigned int v55; // [sp-4h] [bp-18h]@21 |
7645 const char *v56; // [sp+0h] [bp-14h]@0 | 7592 const char *v56; // [sp+0h] [bp-14h]@0 |
7646 int v57; // [sp+4h] [bp-10h]@0 | 7593 int v57; // [sp+4h] [bp-10h]@0 |
7647 unsigned int v58; // [sp+8h] [bp-Ch]@0 | 7594 unsigned int v58; // [sp+8h] [bp-Ch]@0 |
7648 LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 | 7595 //LightmapBuilder *v59; // [sp+Ch] [bp-8h]@3 |
7649 int a3a; // [sp+10h] [bp-4h]@4 | 7596 //int a3a; // [sp+10h] [bp-4h]@4 |
7650 | 7597 |
7651 v8 = this; | 7598 //v8 = this; |
7652 if ( this->uNumD3DSceneBegins && (signed int)uNumVertices >= 3 ) | 7599 if (!uNumD3DSceneBegins || uNumVertices < 3) |
7653 { | 7600 return; |
7654 v59 = pGame->pLightmapBuilder; | 7601 |
7655 v9 = v59->std__vector_000004_size; | 7602 //auto a3 = pFace; |
7656 if ( v9 ) | 7603 //auto a6 = uPackedID; |
7657 a3a = -1; | 7604 //v59 = pGame->pLightmapBuilder; |
7658 else | 7605 //v9 = v59->std__vector_000004_size; |
7659 a3a = a7; | 7606 |
7660 pGame->_44EDE4(a3, &a3a); | 7607 auto uCorrectedColor = uColor; |
7661 if ( byte_4D864C && pGame->uFlags & 1 ) | 7608 if (pGame->pLightmapBuilder->std__vector_000004_size) |
7662 { | 7609 uCorrectedColor = 0xFFFFFFFF; |
7610 pGame->AlterGamma(pFace, &uCorrectedColor); | |
7611 | |
7612 if (byte_4D864C && pGame->uFlags & 1) | |
7613 { | |
7614 __debugbreak(); | |
7663 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | 7615 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
7664 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | 7616 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); |
7665 if ( (signed int)uNumVertices > 0 ) | 7617 if ( (signed int)uNumVertices > 0 ) |
7666 { | 7618 { |
7667 v12 = (char *)&array_507D30[0].vWorldViewPosition; | 7619 v12 = (char *)&array_507D30[0].vWorldViewPosition; |
7668 v13 = (char *)&arary_77E5C8[0].pos.y; | 7620 v13 = (char *)&arary_77E5C8[0].pos.y; |
7669 a7 = uNumVertices; | 7621 auto a7 = uNumVertices; |
7622 uint v18; | |
7670 do | 7623 do |
7671 { | 7624 { |
7672 v14 = *(float *)v12 * 0.061758894; | 7625 v14 = *(float *)v12 * 0.061758894; |
7673 v15 = *((int *)v12 + 3); | 7626 v15 = *((int *)v12 + 3); |
7674 *((int *)v13 + 4) = 0; | 7627 *((int *)v13 + 4) = 0; |
7675 *((int *)v13 - 1) = v15; | 7628 *((int *)v13 - 1) = v15; |
7676 *(int *)v13 = *((int *)v12 + 4); | 7629 *(int *)v13 = *((int *)v12 + 4); |
7677 *((int *)v13 + 3) = a3a; | 7630 *((int *)v13 + 3) = uCorrectedColor; |
7678 v16 = pTex; | 7631 v16 = pTex; |
7679 v13 += 32; | 7632 v13 += 32; |
7680 *((float *)v13 - 7) = 1.0 - 1.0 / v14; | 7633 *((float *)v13 - 7) = 1.0 - 1.0 / v14; |
7681 v17 = 1.0 / *(float *)v12; | 7634 v17 = 1.0 / *(float *)v12; |
7682 v12 += 48; | 7635 v12 += 48; |
7692 } | 7645 } |
7693 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | 7646 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); |
7694 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | 7647 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
7695 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7648 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7696 D3DPT_TRIANGLEFAN, | 7649 D3DPT_TRIANGLEFAN, |
7697 452, | 7650 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7698 arary_77E5C8, | 7651 arary_77E5C8, |
7699 uNumVertices, | 7652 uNumVertices, |
7700 28)); | 7653 28)); |
7701 v59->_45D74F_MessWithLight(-1, 0); | 7654 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
7702 } | 7655 } |
7703 else | 7656 else |
7704 { | 7657 { |
7705 if ( !v9 || byte_4D864C && pGame->uFlags & 2 ) | 7658 if (!pGame->pLightmapBuilder->std__vector_000004_size || |
7706 { | 7659 byte_4D864C && pGame->uFlags & 2) |
7707 if ( (signed int)uNumVertices > 0 ) | 7660 { |
7708 { | 7661 for (uint i = 0; i < uNumVertices; ++i) |
7709 v45 = pTex; | 7662 { |
7710 v46 = (char *)&array_507D30[0].vWorldViewPosition; | 7663 arary_77E5C8[i].pos.x = array_507D30[i].vWorldViewProjX; |
7711 v47 = (char *)&arary_77E5C8[0].pos.y; | 7664 arary_77E5C8[i].pos.y = array_507D30[i].vWorldViewProjY; |
7712 pTex = (Texture *)uNumVertices; | 7665 arary_77E5C8[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); |
7713 do | 7666 arary_77E5C8[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; |
7714 { | 7667 arary_77E5C8[i].diffuse = uCorrectedColor; |
7715 v48 = *(float *)v46 * 0.061758894; | 7668 arary_77E5C8[i].specular = 0; |
7716 v49 = *((int *)v46 + 3); | 7669 arary_77E5C8[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; |
7717 *((int *)v47 + 4) = 0; | 7670 arary_77E5C8[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; |
7718 *((int *)v47 - 1) = v49; | 7671 } |
7719 *(int *)v47 = *((int *)v46 + 4); | 7672 |
7720 *((int *)v47 + 3) = a3a; | 7673 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); |
7721 v47 += 32; | 7674 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); |
7722 *((float *)v47 - 7) = 1.0 - 1.0 / v48; | 7675 ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, |
7723 v50 = 1.0 / *(float *)v46; | 7676 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7724 v46 += 48; | |
7725 v18 = pTex == (Texture *)1; | |
7726 pTex = (Texture *)((char *)pTex - 1); | |
7727 *((float *)v47 - 6) = v50; | |
7728 a7 = v45->uTextureWidth; | |
7729 *((float *)v47 - 3) = *((float *)v46 - 6) / (double)a7; | |
7730 a7 = v45->uTextureHeight; | |
7731 *((float *)v47 - 2) = *((float *)v46 - 5) / (double)a7; | |
7732 } | |
7733 while ( !v18 ); | |
7734 } | |
7735 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | |
7736 ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); | |
7737 v55 = 0; | |
7738 v54 = 1490; | |
7739 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | |
7740 D3DPT_TRIANGLEFAN, | |
7741 452, | |
7742 arary_77E5C8, | 7677 arary_77E5C8, |
7743 uNumVertices, | 7678 uNumVertices, |
7744 28)); | 7679 28)); |
7745 } | 7680 } |
7746 else | 7681 else |
7747 { | 7682 { |
7683 __debugbreak(); | |
7748 if ( (signed int)uNumVertices > 0 ) | 7684 if ( (signed int)uNumVertices > 0 ) |
7749 { | 7685 { |
7750 v23 = pTex; | 7686 v23 = pTex; |
7751 v24 = (char *)&array_507D30[0].vWorldViewPosition; | 7687 v24 = (char *)&array_507D30[0].vWorldViewPosition; |
7752 v25 = (char *)&arary_77E5C8[0].pos.y; | 7688 v25 = (char *)&arary_77E5C8[0].pos.y; |
7753 pTex = (Texture *)uNumVertices; | 7689 pTex = (Texture *)uNumVertices; |
7690 uint v18; | |
7754 do | 7691 do |
7755 { | 7692 { |
7756 v26 = *(float *)v24 * 0.061758894; | 7693 v26 = *(float *)v24 * 0.061758894; |
7757 v27 = *((int *)v24 + 3); | 7694 v27 = *((int *)v24 + 3); |
7758 *((int *)v25 + 4) = 0; | 7695 *((int *)v25 + 4) = 0; |
7759 *((int *)v25 - 1) = v27; | 7696 *((int *)v25 - 1) = v27; |
7760 *(int *)v25 = *((int *)v24 + 4); | 7697 *(int *)v25 = *((int *)v24 + 4); |
7761 *((int *)v25 + 3) = a7; | 7698 *((int *)v25 + 3) = uColor; |
7762 v25 += 32; | 7699 v25 += 32; |
7763 *((float *)v25 - 7) = 1.0 - 1.0 / v26; | 7700 *((float *)v25 - 7) = 1.0 - 1.0 / v26; |
7764 v28 = 1.0 / *(float *)v24; | 7701 v28 = 1.0 / *(float *)v24; |
7765 v24 += 48; | 7702 v24 += 48; |
7766 v18 = pTex == (Texture *)1; | 7703 v18 = pTex == (Texture *)1; |
7767 pTex = (Texture *)((char *)pTex - 1); | 7704 pTex = (Texture *)((char *)pTex - 1); |
7768 *((float *)v25 - 6) = v28; | 7705 *((float *)v25 - 6) = v28; |
7769 a3 = (BLVFace *)v23->uTextureWidth; | 7706 //a3 = (BLVFace *)v23->uTextureWidth; |
7770 *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)a3; | 7707 *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; |
7771 a3 = (BLVFace *)v23->uTextureHeight; | 7708 //a3 = (BLVFace *)v23->uTextureHeight; |
7772 *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)a3; | 7709 *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; |
7773 } | 7710 } |
7774 while ( !v18 ); | 7711 while ( !v18 ); |
7775 } | 7712 } |
7776 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | 7713 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); |
7777 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); | 7714 ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1)); |
7778 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); | 7715 ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); |
7779 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7716 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7780 D3DPT_TRIANGLEFAN, | 7717 D3DPT_TRIANGLEFAN, |
7781 452, | 7718 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7782 arary_77E5C8, | 7719 arary_77E5C8, |
7783 uNumVertices, | 7720 uNumVertices, |
7784 28)); | 7721 28)); |
7785 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); | 7722 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); |
7786 v59->_45D74F_MessWithLight(-1, 0); | 7723 pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); |
7787 v33 = uNumVertices; | 7724 v33 = uNumVertices; |
7788 if ( (signed int)uNumVertices > 0 ) | 7725 if ( (signed int)uNumVertices > 0 ) |
7789 { | 7726 { |
7790 v34 = (char *)&arary_77E5C8[0].diffuse; | 7727 v34 = (char *)&arary_77E5C8[0].diffuse; |
7791 do | 7728 do |
7792 { | 7729 { |
7793 *(int *)v34 = a3a; | 7730 *(int *)v34 = uCorrectedColor; |
7794 v34 += 32; | 7731 v34 += 32; |
7795 --v33; | 7732 --v33; |
7796 } | 7733 } |
7797 while ( v33 ); | 7734 while ( v33 ); |
7798 } | 7735 } |
7802 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true)); | 7739 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, true)); |
7803 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1)); | 7740 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 1)); |
7804 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3)); | 7741 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 3)); |
7805 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 7742 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
7806 D3DPT_TRIANGLEFAN, | 7743 D3DPT_TRIANGLEFAN, |
7807 452, | 7744 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
7808 arary_77E5C8, | 7745 arary_77E5C8, |
7809 uNumVertices, | 7746 uNumVertices, |
7810 28)); | 7747 28)); |
7811 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | 7748 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); |
7812 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1)); | 7749 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1)); |
7813 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, false)); | 7750 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, false)); |
7814 } | |
7815 } | 7751 } |
7816 } | 7752 } |
7817 } | 7753 } |
7818 // 4D864C: using guessed type char byte_4D864C; | 7754 // 4D864C: using guessed type char byte_4D864C; |
7819 | 7755 |
8612 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); | 8548 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); |
8613 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); | 8549 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); |
8614 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); | 8550 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, a9)); |
8615 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | 8551 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( |
8616 D3DPT_TRIANGLEFAN, | 8552 D3DPT_TRIANGLEFAN, |
8617 452, | 8553 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
8618 v29, | 8554 v29, |
8619 4, | 8555 4, |
8620 24)); | 8556 24)); |
8621 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); | 8557 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); |
8622 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); | 8558 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); |
9090 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u)); | 9026 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u)); |
9091 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); | 9027 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); |
9092 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u)); | 9028 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, 8u)); |
9093 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( | 9029 ErrD3D(pRenderD3D->pDevice->DrawPrimitive( |
9094 D3DPT_TRIANGLEFAN, | 9030 D3DPT_TRIANGLEFAN, |
9095 452, | 9031 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, |
9096 v36, | 9032 v36, |
9097 4, | 9033 4, |
9098 28)); | 9034 28)); |
9099 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); | 9035 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); |
9100 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); | 9036 ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); |