Mercurial > mm7
changeset 2155:0a1438c16c2b
Render decoupling.
author | Nomad |
---|---|
date | Thu, 09 Jan 2014 17:29:17 +0200 |
parents | 9bd7522cdbbb |
children | c6d8253d4cbc |
files | AudioPlayer.cpp CastSpellInfo.cpp Chest.cpp DecalBuilder.cpp DecalBuilder.h Game.cpp Game.h IndoorCameraD3D.cpp IndoorCameraD3D.h LightmapBuilder.cpp LightmapBuilder.h Mouse.cpp OSWindow.cpp ParticleEngine.cpp Render.cpp Render.h UI/Books/UIMapBook.cpp UI/UIOptions.cpp UI/UIPopup.cpp UI/UiGame.cpp _deleted.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp mm7_unsorted_subs.h stru6.cpp stru6.h |
diffstat | 27 files changed, 607 insertions(+), 684 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/AudioPlayer.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -56,6 +56,7 @@ void ReleaseSoundData(void *_this); +_DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver();
--- a/CastSpellInfo.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/CastSpellInfo.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -1418,7 +1418,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - int _v726 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096); + int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096); v700.z = 0; v700.y = 0; v700.x = 0; @@ -2393,8 +2393,8 @@ LODWORD(v733) = 300 * v2 + 180; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - int _v726 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); + int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFF, 192); ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); pSpellSprite.spell_id = pCastSpell->uSpellID; @@ -2863,8 +2863,8 @@ amount = 180 * v2; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - int _v726 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); + int _v726 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 192); ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); pSpellSprite.spell_id = pCastSpell->uSpellID; @@ -3251,8 +3251,8 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0Au, 0xC0u); - v505 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0A, 192); + v505 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096); ++pSpellSprite.uType; //signed int _v733 = v505; v688.x = 0; @@ -3372,7 +3372,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - v531 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, 4096); + v531 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, 4096); ++pSpellSprite.uType; v694.x = 0; v694.y = 0; @@ -3909,7 +3909,7 @@ break; pGame->GetIndoorCamera(); v623 = (signed __int64)pGame->pIndoorCameraD3D->GetPickDepth(); - signed int _v733 = _46A6AC_spell_render((int)dword_50BF30.data(), 100, v623); + signed int _v733 = pRenderer->_46A6AC_spell_render_d3d((int)dword_50BF30.data(), 100, v623); v707.x = 0; v707.y = 0; v707.z = 0;
--- a/Chest.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/Chest.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -814,7 +814,7 @@ else { v1 = pMouse->GetCursorPos(&a2); - v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF; + v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v7)->y]] & 0xFFFF; if ( v2 ) { if ( v2 )
--- a/DecalBuilder.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/DecalBuilder.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -648,79 +648,12 @@ return result; } -//----- (0049C095) -------------------------------------------------------- -void DecalBuilder::DrawDecal(Decal *pDecal, float z_bias) -{ - signed int v21; // [sp+Ch] [bp-864h]@15 - RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 - - if (pDecal->uNumVertices < 3) - { - Log::Warning(L"Decal has < 3 vertices"); - return; - } - - float color_mult; - if ( pDecal->field_C1C & 1 ) - color_mult = 1.0; - else - color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); - - for (uint i = 0; i < pDecal->uNumVertices; ++i) - { - uint uTint = pRenderer->GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); - - uint uTintR = (uTint >> 16) & 0xFF, - uTintG = (uTint >> 8) & 0xFF, - uTintB = uTint & 0xFF; - - uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, - uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, - uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; - - uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), - uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), - uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); - - - float v15; - if (fabs(z_bias) < 1e-5) - v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); - else - { - v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; - if (v15 < 0.000099999997) - v15 = 0.000099999997; - } - - pVerticesD3D[i].pos.z = v15; - - pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; - pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; - pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; - pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; - pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; - pVerticesD3D[i].specular = 0; - pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; - } - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; - else - v21 = D3DDP_DONOTLIGHT; - - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - pVerticesD3D, - pDecal->uNumVertices, - v21)); -} //----- (0049C2CD) -------------------------------------------------------- void DecalBuilder::DrawDecals(float z_bias) { for (uint i = 0; i < std__vector_pDecals_size; ++i) - DrawDecal(std__vector_pDecals + i, z_bias); + pRenderer->DrawDecal(std__vector_pDecals + i, z_bias); } //----- (0049C304) -------------------------------------------------------- @@ -729,29 +662,11 @@ if (!std__vector_pDecals_size) return; - if (pRenderer->bUsingSpecular) - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); + pRenderer->BeginDecals(); - IDirect3DTexture2* pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex)); - DrawDecals(0.00039999999); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); - if (pRenderer->bUsingSpecular) - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); + pRenderer->EndDecals(); } //----- (0049C550) --------------------------------------------------------
--- a/DecalBuilder.h Thu Jan 09 14:36:48 2014 +0200 +++ b/DecalBuilder.h Thu Jan 09 17:29:17 2014 +0200 @@ -172,7 +172,6 @@ bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID); char ApplyDecals_OutdoorFace(ODMFace *pFace); bool _49BE8A(struct Polygon *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7); - void DrawDecal(Decal *pDecal, float z_bias); void DrawDecals(float z_bias); void DrawBloodsplats(); void DrawDecalDebugOutlines();
--- a/Game.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/Game.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -171,7 +171,7 @@ if ( !PauseGameDrawing() /*&& pRenderer->pRenderD3D*/) // clear game viewport with transparent color pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, - pRenderer->uTargetGMask | pRenderer->uTargetBMask); + 0x7FF); viewparams->field_48 = 0; } } @@ -703,8 +703,8 @@ //----- (004645FA) -------------------------------------------------------- void Game::Deinitialize() { - WriteWindowsRegistryInt("startinwindow", pRenderer->bWindowMode); - if (pRenderer->bWindowMode) + WriteWindowsRegistryInt("startinwindow", 1);//pRenderer->bWindowMode); + //if (pRenderer->bWindowMode) { WriteWindowsRegistryInt("window X", window->GetX()); WriteWindowsRegistryInt("window Y", window->GetY()); @@ -1011,10 +1011,10 @@ { v7 = 1.0; } - if ( pRenderer->pRenderD3D ) + //if ( pRenderer->pRenderD3D ) fSaturation = v7; - else - fSaturation = (1.0 - 0.5) * v7 + 0.5; + //else + // fSaturation = (1.0 - 0.5) * v7 + 0.5; } //----- (0044EA17) -------------------------------------------------------- @@ -1785,7 +1785,7 @@ pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleColoredLights, 0, 0, "", 0); pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleTint, 0, 0, "", 0); } - if ( !pRenderer->bWindowMode ) + /*if ( !pRenderer->bWindowMode ) { //v0 = 1; if ( pRenderer->IsGammaSupported() ) @@ -1794,7 +1794,7 @@ pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 5u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C24), 0); pGUIWindow_CurrentMenu->CreateButton(42, 162, 170, 18, 1, 0, UIMSG_1A9, 0, 0, "", 0); } - } + }*/ continue; case UIMSG_1A9: __debugbreak(); @@ -2263,8 +2263,8 @@ WriteWindowsRegistryInt("Tinting", pRenderer->bTinting); WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1); } - if ( !pRenderer->bWindowMode ) - WriteWindowsRegistryInt("GammaPos", uGammaPos); + /*if ( !pRenderer->bWindowMode ) + WriteWindowsRegistryInt("GammaPos", uGammaPos);*/ stru_506E40.Release(); break;
--- a/Game.h Thu Jan 09 14:36:48 2014 +0200 +++ b/Game.h Thu Jan 09 17:29:17 2014 +0200 @@ -2,7 +2,7 @@ #include "VectorTypes.h" -#define GAME_FLAGS_1_01 0x01 +#define GAME_FLAGS_1_01_lightmap_related 0x01 #define GAME_FLAGS_1_DRAW_BLV_DEBUGS 0x08 #define GAME_FLAGS_2_SATURATE_LIGHTMAPS 0x02 #define GAME_FLAGS_2_ALTER_GRAVITY 0x08
--- a/IndoorCameraD3D.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/IndoorCameraD3D.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -559,40 +559,6 @@ return true; } -//----- (00437C96) -------------------------------------------------------- -void IndoorCameraD3D::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) -{ - double v6; // st7@2 - //IDirect3DDevice3 *v7; // eax@2 - HRESULT v8; // eax@2 - std::string v9; // [sp-18h] [bp-60h]@3 - const char *v10; // [sp-Ch] [bp-54h]@2 - const char *v11; // [sp-8h] [bp-50h]@2 - int v12; // [sp-4h] [bp-4Ch]@2 - RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 - - //if ( pRenderer->pRenderD3D ) - { - v6 = 0.001 - z_stuff; - memcpy(v13, pLineBegin, 0x20u); - memcpy(&v13[1], pLineEnd, sizeof(v13[1])); - v13[0].pos.z = v6; - v13[1].pos.z = v6; - v12 = 0; - v13[0].diffuse = sDiffuseBegin; - v13[1].diffuse = sDiffuseEnd; - //v7 = pRenderer->pRenderD3D->pDevice; - v11 = 0; - //v10 = (const char *)v7; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( - D3DPT_LINELIST, - 452, - v13, - 2, - 16)); - } -} //----- (00437AB5) -------------------------------------------------------- void IndoorCameraD3D::do_draw_debug_line_sw(RenderVertexSoft *pLineBegin, signed int sStartDiffuse, RenderVertexSoft *pLineEnd, signed int sEndDiffuse, unsigned int uOutNumVertices, float z_stuff) @@ -658,13 +624,7 @@ v24[1].texcoord.x = 0.0; v24[1].texcoord.y = 0.0; //v19 = pRenderer->pRenderD3D->pDevice; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( - D3DPT_LINELIST, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - v24, - 2, - 16)); + pRenderer->DrawLines(v24, 2); return; } v11 = (char *)&a1[0].flt_2C; @@ -725,13 +685,13 @@ do { v8 = v6 + 1; - do_draw_debug_line_d3d(v6, uDiffuse, v6 + 1, uDiffuse, z_stuff); + pRenderer->do_draw_debug_line_d3d(v6, uDiffuse, v6 + 1, uDiffuse, z_stuff); --v7; v6 = v8; } while ( v7 ); } - do_draw_debug_line_d3d(&pLineVertices[v5], uDiffuse, pLineVertices, uDiffuse, z_stuff); + pRenderer->do_draw_debug_line_d3d(&pLineVertices[v5], uDiffuse, pLineVertices, uDiffuse, z_stuff); } //----- (004379EE) -------------------------------------------------------- @@ -793,25 +753,7 @@ v[i].texcoord.y = 0; } - - //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); - //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - v, - pFace->uNumVertices, - 28)); - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); - //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); - //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); + pRenderer->DrawFansTransparent(v, pFace->uNumVertices); } //----- (00437906) --------------------------------------------------------
--- a/IndoorCameraD3D.h Thu Jan 09 14:36:48 2014 +0200 +++ b/IndoorCameraD3D.h Thu Jan 09 17:29:17 2014 +0200 @@ -153,7 +153,6 @@ void debug_outline_sw(struct RenderVertexSoft *a2, unsigned int uNumVertices, unsigned int uDiffuse, float a5); void debug_outline_d3d(const struct RenderVertexD3D3 *pLineVertices, unsigned int uNumLines, int uDiffuse, float z_stuff); void do_draw_debug_line_sw(struct RenderVertexSoft *pLineBegin, signed int sStartDiffuse, struct RenderVertexSoft *pLineEnd, signed int sEndDiffuse, unsigned int uOutNumVertices, float z_stuff); - void do_draw_debug_line_d3d(const struct RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff); //void sr_437D4A_draw_some_vertices(float x, float y, float z, unsigned int a5, char a6, float a7); //void sr_438141_draw_list_0037C(); //void sr_438240_draw_lits();
--- a/LightmapBuilder.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/LightmapBuilder.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -1376,7 +1376,7 @@ IDirect3DDevice3 *v4; // eax@2 HRESULT v5; // eax@2 //char *v6; // eax@2 - struct IDirect3DTexture2 *v7; // edi@4 + //struct IDirect3DTexture2 *v7; // edi@4 HRESULT v8; // eax@8 HRESULT v9; // eax@8 HRESULT v10; // eax@8 @@ -1410,22 +1410,12 @@ //float v38; // [sp+84h] [bp-4h]@1 if (std__vector_000004_size == 0) - return 1; - - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); + return true; + + if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) + return true; - v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"); - if ( pRenderer->bUsingSpecular ) - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); - - if ( !byte_4D864C || !(pGame->uFlags & GAME_FLAGS_1_01) ) - { - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); + pRenderer->BeginLightmaps(); arg4.x = 1.0f; arg4.y = 1.0f; @@ -1435,7 +1425,7 @@ for (int* i = indices; *i != -1; ++i) { v28 = &std__vector_000004[*i]; - if ( !DrawLightmap(v28, &arg4, 0.0) ) + if ( !pRenderer->DrawLightmap(v28, &arg4, 0.0) ) Error("Invalid lightmap detected! (%u)", *i); } } @@ -1444,35 +1434,13 @@ for (unsigned int i = 0; i < std__vector_000004_size; ++i) { Lightmap* _a1 = &std__vector_000004[(int)i]; - if ( !DrawLightmap(_a1, &arg4, 0.0) ) - { - MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1238", 0); - v35 = 5080812; - } + if ( !pRenderer->DrawLightmap(_a1, &arg4, 0.0) ) + Error("Invalid lightmap detected! (%u)", i); } } - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); - } - - if ( pRenderer->bUsingSpecular ) - { - //LODWORD(v30) = 1; - //v29 = 28; - //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); - //v30 = pRenderer->uFogColor; - //v23 = pRenderer->pRenderD3D->pDevice; - //v29 = 34; - //v28 = (Lightmap *)v23; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, pRenderer->uFogColor)); - //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); - } - + pRenderer->EndLightmaps(); + return true; } @@ -1486,14 +1454,14 @@ v.x = 1.0; for (uint i = 0; i < std__vector_183808_size; ++i) - if (!DrawLightmap(std__vector_183808 + i, &v, z_bias)) - MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1288", 0); + if (!pRenderer->DrawLightmap(std__vector_183808 + i, &v, z_bias)) + Error("Invalid lightmap detected! (%u)", i); return true; } //----- (0045DAE8) -------------------------------------------------------- -bool LightmapBuilder::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias) +bool Render::DrawLightmap(Lightmap *pLightmap, Vec3_float_ *pColorMult, float z_bias) { double v10; // st7@4 double v14; // st7@7 @@ -1568,29 +1536,9 @@ if (!std__vector_183808_size) return; - if (pRenderer->bUsingSpecular) - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); - - IDirect3DTexture2* pTex = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pTex)); - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); + pRenderer->BeginLightmaps2(); DoDraw_183808_Lightmaps(0.00050000002); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); - - if (pRenderer->bUsingSpecular) - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); + pRenderer->EndLightmaps2(); } \ No newline at end of file
--- a/LightmapBuilder.h Thu Jan 09 14:36:48 2014 +0200 +++ b/LightmapBuilder.h Thu Jan 09 17:29:17 2014 +0200 @@ -36,7 +36,7 @@ {} void Draw_183808_Lightmaps(); - bool DrawLightmap(Lightmap *a1, Vec3_float_ *pColorMult, float z_bias); + //bool DrawLightmap(Lightmap *a1, Vec3_float_ *pColorMult, float z_bias); bool DoDraw_183808_Lightmaps(float a2); bool DrawLightmaps(int *indices = nullptr); void DrawLightmapsType(int type);
--- a/Mouse.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/Mouse.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -109,7 +109,7 @@ //} v1->uMouseClickX = v2; v1->uMouseClickY = result; - if ( pRenderer->bWindowMode ) + if ( true/*pRenderer->bWindowMode*/) goto LABEL_16; //if (pAsyncMouse) // goto LABEL_24; @@ -125,7 +125,7 @@ LABEL_16: //if (pAsyncMouse) // goto LABEL_24; - if ( pRenderer->bWindowMode && (v2 < 0 || result < 0 || v2 > 639 || result > 479) ) + if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > 639 || result > 479) ) goto LABEL_23; } if ( v1->field_C ) @@ -235,7 +235,8 @@ this->field_F4 = 0; return; } - if ( pRenderer->bWindowMode ) + + //if ( pRenderer->bWindowMode ) { if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > 639 || this->uMouseClickY > 479 ) { @@ -243,7 +244,7 @@ return; } } - else + /*else { if ( this->uMouseClickX < 0 ) this->uMouseClickX = 0; @@ -253,7 +254,7 @@ this->uMouseClickX = 639; if ( this->uMouseClickY > 479 ) this->uMouseClickY = 479; - } + }*/ this->pCursorBitmapRect.x = this->uMouseClickX; this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0]; this->pCursorBitmapRect.y = this->uMouseClickY;
--- a/OSWindow.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/OSWindow.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -352,7 +352,7 @@ if (!api_handle || !pRenderer) return false; - if ( !GetUpdateRect(api_handle, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode ) + if ( !GetUpdateRect(api_handle, 0, 0))// || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode ) return *result = 0, true; PAINTSTRUCT Paint;
--- a/ParticleEngine.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/ParticleEngine.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -144,13 +144,14 @@ { if (pLines.uNumLines) { - pRenderer->pRenderD3D->pDevice->SetTexture(0, 0); + pRenderer->DrawLines(pLines.pLineVertices, pLines.uNumLines); + /*pRenderer->pRenderD3D->pDevice->SetTexture(0, 0); pRenderer->pRenderD3D->pDevice->DrawPrimitive( D3DPT_LINELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pLines.pLineVertices, pLines.uNumLines, - D3DDP_DONOTLIGHT); + D3DDP_DONOTLIGHT);*/ } } } @@ -649,10 +650,10 @@ p->uScreenSpaceY >= pBLVRenderParams->uViewportY && p->uScreenSpaceY < pBLVRenderParams->uViewportW) { - if (!pRenderer->pRenderD3D) + /*if (!pRenderer->pRenderD3D) { __debugbreak(); - /*v11 = 13 * p->_screenspace_scale >> 16; + v11 = 13 * p->_screenspace_scale >> 16; if ( v11 > 30 ) v11 = 30; v12 = p->uScreenSpaceY - v11; @@ -667,9 +668,9 @@ else { pRenderer->MakeParticleBillboardAndPush_BLV_Software(v13, v12, p->sZValue, p->uLightColor_bgr, v11); - }*/ + } } - //else + else*/ if (p->type & ParticleType_Diffuse) {
--- a/Render.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/Render.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -28,6 +28,7 @@ #include "MM7.h" #include "Lights.h" #include "Level/Decoration.h" +#include "Vis.h" //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") //#pragma comment(lib, "lib\\legacy_dx\\lib\\dxguid.lib") @@ -121,34 +122,6 @@ return v0; } -void Render::sub_4A19B0() -{ - char *result; // eax@1 - signed int v1; // ecx@1 - /* - result = (char *)&this->pBillboardRenderListD3D[0].uOpacity; - v1 = 1000; - do - { - *(_DWORD *)result = 0; - *((_DWORD *)result + 1) = -1; - *((_DWORD *)result + 3) = -1; - *((_DWORD *)result - 34) = 4; - result += 156; - --v1; - } - while ( v1 ); - */ - for( int i = 0; i < 1000; i++ ) - { - this->pBillboardRenderListD3D[i].uOpacity = (RenderBillboardD3D::OpacityType)0; - this->pBillboardRenderListD3D[i].field_90 = -1; - this->pBillboardRenderListD3D[i].sParentBillboardID = -1; - this->pBillboardRenderListD3D[i].uNumVertices = 4; - } - - return; -} //----- (00440CB8) -------------------------------------------------------- void Render::DrawBillboardList_BLV() @@ -1915,7 +1888,7 @@ if ( v7->std__vector_000004_size) a2 = -1; pGame->AlterGamma_ODM(a4, &a2); - if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) + if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) { v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); v7->DrawLightmaps(/*v8, 0*/); @@ -2077,17 +2050,6 @@ //nullsub_1(); } -//----- (0049E756) -------------------------------------------------------- -bool Render::IsColorKeySupported(IDirectDraw4 *this_) -{ - DDCAPS refCaps; // [sp+0h] [bp-2F8h]@1 - DDCAPS halCaps; // [sp+17Ch] [bp-17Ch]@1 - - halCaps.dwSize = 380; - refCaps.dwSize = 380; - this_->GetCaps(&halCaps, &refCaps); - return halCaps.dwSVBCaps & 0x40 && BYTE1(halCaps.dwSVBCKeyCaps) & 2; -} //----- (0049E992) -------------------------------------------------------- Render::Render() @@ -2147,7 +2109,6 @@ hd_water_tile_id = -1; hd_water_current_frame = 0; - sub_4A19B0(); } bool Render::Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) @@ -2360,7 +2321,6 @@ } } } -// 4EFA80: using guessed type int dword_4EFA80; //----- (0049F1BC) -------------------------------------------------------- void Render::SaveWinnersCertificate(const char *a1) @@ -2670,7 +2630,7 @@ } //----- (0049F8B5) -------------------------------------------------------- -FILE *Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) +void Render::SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height) { FILE *result; // eax@1 FILE *pOutFile; // edi@4 @@ -2786,9 +2746,8 @@ v9 += width; } free(lineRGB); - result = (FILE *)fclose(pOutFile); - } - return result; + fclose(pOutFile); + } } //----- (0049FBCD) -------------------------------------------------------- @@ -2803,12 +2762,6 @@ //memset32(pTargetSurface, uColor, field_10 * field_14 / 2); } -//----- (0049FC23) -------------------------------------------------------- -void Render::Release2() -{ - Release(); - bWindowMode = 1; -} //----- (0049FC37) -------------------------------------------------------- void Render::Present() @@ -3046,7 +2999,7 @@ for (uint x = pViewport->uViewportTL_X; x < pViewport->uViewportBR_X; ++x) { //if (src[x + y * src_pitch] != (pRenderer->uTargetGMask | pRenderer->uTargetBMask)) - if (src[x + y * src_pitch] != 0xFFF8FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) + if (src[x + y * src_pitch] != 0xFF00FCF8) // FFF8FCF8 = Color32(Color16(g_mask | b_mask)) dst[x + y * dst_pitch] = src[x + y * src_pitch]; } } @@ -4342,44 +4295,6 @@ pBackBuffer4->Restore(); } -//----- (004A1884) -------------------------------------------------------- -void Render::PresentRect(RECT *a2, RECT *a3) -{ - IDirectDrawSurface *pFront; // eax@3 - HRESULT v4; // eax@5 - IDirectDrawSurface *pBack; // [sp-1Ch] [bp-1Ch]@3 - struct tagRECT *v6; // [sp-18h] [bp-18h]@3 - DWORD v7; // [sp-14h] [bp-14h]@3 - DDBLTFX *v8; // [sp-10h] [bp-10h]@3 - const char *v9; // [sp-Ch] [bp-Ch]@3 - int v10; // [sp-8h] [bp-8h]@3 - unsigned int v11; // [sp-4h] [bp-4h]@3 - - //if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) - { - v11 = 0; - pFront = (IDirectDrawSurface *)this->pFrontBuffer4; - v10 = 2657; - v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; - v8 = 0; - v7 = DDBLT_WAIT; - v6 = a3; - pBack = (IDirectDrawSurface *)this->pBackBuffer4; - } - /*else - { - v11 = 0; - pFront = (IDirectDrawSurface *)this->pFrontBuffer2; - v10 = 2653; - v9 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Screen16.cpp"; - v8 = 0; - v7 = DDBLT_WAIT; - v6 = a3; - pBack = (IDirectDrawSurface *)this->pBackBuffer2; - }*/ - ErrD3D(pFront->Blt(a2, pBack, v6, v7, v8)); -} - //----- (004A18F5) -------------------------------------------------------- void Render::BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags) { @@ -4758,7 +4673,7 @@ /* v9 = pGame->pLightmapBuilder; v65 = v9; v10 = v9->std__vector_000004_size;*/ - if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) + if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) { v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); @@ -5394,7 +5309,7 @@ else uColor = sCorrectedColor = 0xFF109010; } - if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) + if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01_lightmap_related) { __debugbreak(); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); @@ -5580,9 +5495,9 @@ //v9 = v7; v28 = dimming_level & 0xFF000000; if ( dimming_level & 0xFF000000 ) - pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Opaque_3; + pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Opaque_3; else - pBillboardRenderListD3D[v7].uOpacity = RenderBillboardD3D::Transparent; + pBillboardRenderListD3D[v7].opacity = RenderBillboardD3D::Transparent; //v10 = a3; pBillboardRenderListD3D[v7].field_90 = pSoftBillboard->field_44; pBillboardRenderListD3D[v7].sZValue = pSoftBillboard->sZValue; @@ -5716,7 +5631,7 @@ //v6 = v5; //v7 = v5; v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; + pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; pBillboardRenderListD3D[v8].field_90 = a2->field_44; pBillboardRenderListD3D[v8].sZValue = a2->sZValue; pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; @@ -5889,7 +5804,7 @@ v6 = v5; v7 = v5; v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_1; + pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_1; pBillboardRenderListD3D[v8].field_90 = a2->field_44; pBillboardRenderListD3D[v8].sZValue = a2->sZValue; pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; @@ -6109,9 +6024,9 @@ pBillboardRenderListD3D[v8].sParentBillboardID = a2->sParentBillboardID; if (a2->sTintColor & 0xFF000000) - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; + pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Opaque_3; else - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; + pBillboardRenderListD3D[v8].opacity = RenderBillboardD3D::Transparent; } @@ -6240,7 +6155,7 @@ v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); pBillboardRenderListD3D[v5].field_90 = 0; pBillboardRenderListD3D[v5].sParentBillboardID = -1; - pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; + pBillboardRenderListD3D[v5].opacity = RenderBillboardD3D::Opaque_2; pBillboardRenderListD3D[v5].pTexture = 0; pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; pBillboardRenderListD3D[v5].z_order = depth; @@ -6496,12 +6411,12 @@ } } -//----- ( ) -------------------------------------------------------- -unsigned int Render::_4A52F1(unsigned int this_, float a3) +//----- (004A52F1) -------------------------------------------------------- +void Render::ScreenFade(unsigned int color, float t) { unsigned int v3; // esi@1 - double v4; // st7@2 - double v5; // st7@6 + //double v4; // st7@2 + //double v5; // st7@6 double v6; // st6@6 unsigned int v7; // eax@6 double v8; // st5@6 @@ -6536,36 +6451,22 @@ unsigned int v37; // [sp+8Ch] [bp-14h]@7 int v38; // [sp+90h] [bp-10h]@7 double v39; // [sp+94h] [bp-Ch]@6 - float v40; // [sp+9Ch] [bp-4h]@6 - - __debugbreak(); - - Render* ecx0 = this; + int v40; // [sp+9Ch] [bp-4h]@6 + v3 = 0; - if (!this->pRenderD3D) - __debugbreak(); // sw render - //{ - v4 = a3; - if ( a3 <= 1.0 ) - { - if ( v4 < 0.0 ) - v4 = 0.0; - } - else - { - v4 = 1.0; - } - __debugbreak(); // banker's rounding again - a3 = v4 * 255.0; - v39 = a3 + 6.7553994e15; - LODWORD(v40) = LODWORD(v39); - v5 = (double)(signed int)pViewport->uViewportTL_X; - v36[0].pos.x = v5; + if (t > 1.0f) + t = 1.0f; + else if (t < 0.0f) + t = 0.0f; + + v40 = (char)floorf(t * 255.0f + 0.5f); + //v5 = (double)(signed int)pViewport->uViewportTL_X; + v36[0].pos.x = pViewport->uViewportTL_X; v6 = (double)(signed int)pViewport->uViewportTL_Y; - v7 = this_ | (LODWORD(v39) << 24); - this_ = pViewport->uViewportBR_Y + 1; + v7 = color | (v40 << 24); + //this_ = pViewport->uViewportBR_Y + 1; v36[0].specular = 0; v36[0].pos.y = v6; v36[0].diffuse = v7; @@ -6579,7 +6480,7 @@ v36[2].specular = 0; v36[3].specular = 0; v36[0].texcoord.y = 0.0; - v36[1].pos.x = v5; + v36[1].pos.x = pViewport->uViewportTL_X; v8 = (double)(pViewport->uViewportBR_Y + 1); v36[1].pos.y = v8; v36[1].pos.z = 0.0; @@ -6706,7 +6607,6 @@ while ( v32 != 1 ); } }*/ - return result; } //----- (004A5B81) -------------------------------------------------------- @@ -6891,7 +6791,7 @@ } //----- (004A6E7E) -------------------------------------------------------- -void Render::_4A6E7E(unsigned int a2, unsigned int a3, Texture *a4) +void Render::DrawTranslucent(unsigned int a2, unsigned int a3, Texture *a4) { //unsigned __int16 *v4; // eax@4 int v5; // edx@4 @@ -8685,8 +8585,8 @@ for (int i = uNumBillboardsToDraw - 1; i >= 0; --i) { - if (pBillboardRenderListD3D[i].uOpacity != RenderBillboardD3D::NoBlend) - SetBillboardBlendOptions(pBillboardRenderListD3D[i].uOpacity); + if (pBillboardRenderListD3D[i].opacity != RenderBillboardD3D::NoBlend) + SetBillboardBlendOptions(pBillboardRenderListD3D[i].opacity); pRenderD3D->pDevice->SetTexture(0, pBillboardRenderListD3D[i].pTexture); @@ -9395,3 +9295,302 @@ pRenderer->PackPCXpicture(pixels, 150, 112, data, 1000000, out_screenshot_size); free(pixels); } + + +//----- (0046A7C8) -------------------------------------------------------- +int Render::_46A6AC_spell_render_d3d(int a1, int a2, int a3) +{ + unsigned int v3; // eax@2 + unsigned int v5; // eax@2 + unsigned int v6; // eax@4 + int v10; // ecx@11 + unsigned int v12; // [sp+10h] [bp-14h]@1 + int v15; // [sp+1Ch] [bp-8h]@1 + unsigned int a1a; // [sp+20h] [bp-4h]@1 + + v15 = 0; + v12 = GetBillboardDrawListSize(); + if ( (signed int)GetBillboardDrawListSize() > 0 ) + { + for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) + { + v3 = GetParentBillboardID(a1a); + v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; + if ( PID_TYPE(v5) == OBJECT_Actor) + { + if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) ) + { + v6 = PID_ID(v5); + if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed + && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) + { + if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) ) + { + if ( v15 < a2 - 1 ) + { + __debugbreak();// *(int *)(a1 + 4 * v10) = v6; что это такое? + v10 = v15++; + *(int *)(a1 + 4 * v10) = v6; + } + } + } + } + } + } + } + return v15; +} + + + + +void Render::BeginLightmaps() +{ + ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); + + if (bUsingSpecular) + pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); + + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); +} + +void Render::EndLightmaps() +{ + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); + + if (bUsingSpecular) + { + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, uFogColor)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); + } +} + + +void Render::BeginLightmaps2() +{ + if (bUsingSpecular) + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); + + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); + + ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"))); + + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); +} + + +void Render::EndLightmaps2() +{ + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); + + if (bUsingSpecular) + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); +} + + + +//----- (00437C96) -------------------------------------------------------- +void Render::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff) +{ + double v6; // st7@2 + //IDirect3DDevice3 *v7; // eax@2 + HRESULT v8; // eax@2 + std::string v9; // [sp-18h] [bp-60h]@3 + const char *v10; // [sp-Ch] [bp-54h]@2 + const char *v11; // [sp-8h] [bp-50h]@2 + int v12; // [sp-4h] [bp-4Ch]@2 + RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 + + //if ( pRenderer->pRenderD3D ) + { + v6 = 0.001 - z_stuff; + memcpy(v13, pLineBegin, 0x20u); + memcpy(&v13[1], pLineEnd, sizeof(v13[1])); + v13[0].pos.z = v6; + v13[1].pos.z = v6; + v13[0].diffuse = sDiffuseBegin; + v13[1].diffuse = sDiffuseEnd; + ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); + ErrD3D(pRenderD3D->pDevice->DrawPrimitive( + D3DPT_LINELIST, + 452, + v13, + 2, + 16)); + } +} + + +void Render::DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices) +{ + ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); + ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_LINELIST, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + (void *)vertices, + num_vertices, + D3DDP_DONOTLIGHT)); +} + + +void Render::DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices) +{ + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); + + ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); + ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + (void *)vertices, + num_vertices, + 28)); + + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); + //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); +} + + +void Render::BeginDecals() +{ + // code chunk from 0049C304 + if (bUsingSpecular) + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); + + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); + + ErrD3D(pRenderD3D->pDevice->SetTexture(0, pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("hwsplat04"))); +} + + +void Render::EndDecals() +{ + // code chunk from 0049C304 + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CW)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); + + if (bUsingSpecular) + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, TRUE)); +} + + + +//----- (0049C095) -------------------------------------------------------- +void Render::DrawDecal(Decal *pDecal, float z_bias) +{ + signed int v21; // [sp+Ch] [bp-864h]@15 + RenderVertexD3D3 pVerticesD3D[64]; // [sp+20h] [bp-850h]@6 + + if (pDecal->uNumVertices < 3) + { + Log::Warning(L"Decal has < 3 vertices"); + return; + } + + float color_mult; + if ( pDecal->field_C1C & 1 ) + color_mult = 1.0; + else + color_mult = pDecal->field_C18->_43B570_get_color_mult_by_time(); + + for (uint i = 0; i < pDecal->uNumVertices; ++i) + { + uint uTint = Render::GetActorTintColor(pDecal->pVertices[i].vWorldViewPosition.x, pDecal->field_C14, 0, 0, nullptr); + + uint uTintR = (uTint >> 16) & 0xFF, + uTintG = (uTint >> 8) & 0xFF, + uTintB = uTint & 0xFF; + + uint uDecalColorMultR = (pDecal->uColorMultiplier >> 16) & 0xFF, + uDecalColorMultG = (pDecal->uColorMultiplier >> 8) & 0xFF, + uDecalColorMultB = pDecal->uColorMultiplier & 0xFF; + + uint uFinalR = floorf(uTintR / 255.0 * color_mult * uDecalColorMultR + 0.0f), + uFinalG = floorf(uTintG / 255.0 * color_mult * uDecalColorMultG + 0.0f), + uFinalB = floorf(uTintB / 255.0 * color_mult * uDecalColorMultB + 0.0f); + + + float v15; + if (fabs(z_bias) < 1e-5) + v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0); + else + { + v15 = 1.0 - 1.0 / ((1.0f / pGame->pIndoorCameraD3D->GetShadingDistMist()) * pDecal->pVertices[i].vWorldViewPosition.x * 1000.0) - z_bias; + if (v15 < 0.000099999997) + v15 = 0.000099999997; + } + + pVerticesD3D[i].pos.z = v15; + + pVerticesD3D[i].pos.x = pDecal->pVertices[i].vWorldViewProjX; + pVerticesD3D[i].pos.y = pDecal->pVertices[i].vWorldViewProjY; + pVerticesD3D[i].texcoord.x = pDecal->pVertices[i].u; + pVerticesD3D[i].texcoord.y = pDecal->pVertices[i].v; + pVerticesD3D[i].diffuse = (uFinalR << 16) | (uFinalG << 8) | uFinalB; + pVerticesD3D[i].specular = 0; + pVerticesD3D[i].rhw = 1.0 / pDecal->pVertices[i].vWorldViewPosition.x; + } + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + v21 = D3DDP_DONOTLIGHT | D3DDP_DONOTCLIP | D3DDP_DONOTUPDATEEXTENTS; + else + v21 = D3DDP_DONOTLIGHT; + + ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + pVerticesD3D, + pDecal->uNumVertices, + v21)); +} + + +void Render::DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture) +{ + ErrD3D(pRenderD3D->pDevice->SetTexture(0, texture)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS)); + ErrD3D(pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + (void *)vertices, 4, 28)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS)); +} \ No newline at end of file
--- a/Render.h Thu Jan 09 14:36:48 2014 +0200 +++ b/Render.h Thu Jan 09 17:29:17 2014 +0200 @@ -198,20 +198,27 @@ #pragma pack(push, 1) struct RenderBillboardD3D { - enum OpacityType: signed __int32 + inline RenderBillboardD3D(): + opacity(Transparent), + field_90(-1), + sParentBillboardID(-1), + uNumVertices(4) + {} + + enum OpacityType: unsigned __int32 { Transparent = 0, Opaque_1 = 1, Opaque_2 = 2, Opaque_3 = 3, - NoBlend = -1 + NoBlend = 0xFFFFFFFF }; IDirect3DTexture2 *pTexture; unsigned int uNumVertices; RenderVertexD3D3 pQuads[4]; float z_order; - OpacityType uOpacity; + OpacityType opacity; int field_90; int sZValue; signed int sParentBillboardID; @@ -283,16 +290,11 @@ bool Initialize(OSWindow *window, bool bColoredLights, uint32_t uDetailLevel, bool bTinting); - bool IsColorKeySupported(IDirectDraw4 *); - void _stub_49EBF1(); void ClearBlack(); void PresentBlackScreen(); void SavePCXScreenshot(); void SaveWinnersCertificate(const char *a1); - void PackPCXpicture(unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size); - FILE *SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height); void ClearTarget(unsigned int uColor); - void Release2(); void Present(); void _49FD3A_fullscreen(); void CreateZBuffer(); @@ -302,15 +304,7 @@ void RasterLine2D(signed int uX, signed int uY, signed int uZ, signed int uW, unsigned __int16 uColor); void ClearZBuffer(int a2, int a3); void SetRasterClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); - void ParseTargetPixelFormat(); bool LockSurface_DDraw4(IDirectDrawSurface4 *pSurface, DDSURFACEDESC2 *pDesc, unsigned int uLockFlags); - void CreateDirectDraw(); - void SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen); - void SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP); - void CreateFrontBuffer(); - void CreateBackBuffer(); - void CreateDirectDrawPrimarySurface(); - void CreateClipper(HWND a2); void GetTargetPixelFormat(DDPIXELFORMAT *pOut); void LockRenderSurface(void **pOutSurfacePtr, unsigned int *pOutPixelsPerRow); void UnlockBackBuffer(); @@ -318,12 +312,8 @@ void UnlockFrontBuffer(); void RestoreFrontBuffer(); void RestoreBackBuffer(); - void PresentRect(RECT *a2, RECT *a3); void BltToFront(RECT *pDstRect, IDirectDrawSurface *pSrcSurface, RECT *pSrcRect, unsigned int uBltFlags); void BltBackToFontFast(int a2, int a3, RECT *a4); - unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z); - unsigned int GetBillboardDrawListSize(); - unsigned int GetParentBillboardID(unsigned int uBillboardID); void BeginSceneD3D(); void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6); @@ -335,16 +325,14 @@ void DrawIndoorSky(unsigned int uNumVertices, unsigned int uFaceID); void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); - void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard); void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level); - //int MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6); void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); void _4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse); bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture); bool MoveSpriteToDevice(Sprite *pSprite); void BeginScene(); void EndScene(); - unsigned int _4A52F1(unsigned int this_, float a3); + void ScreenFade(unsigned int color, float t); void SetTextureClipRect(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW); void ResetTextureClipRect(); void DrawTextureRGB(unsigned int uOutX, unsigned int uOutY, RGBTexture *a4); @@ -363,7 +351,7 @@ void DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor); void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16); void _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7); - void _4A6E7E(unsigned int a2, unsigned int a3, struct Texture *a4); + void DrawTranslucent(unsigned int a2, unsigned int a3, struct Texture *a4); void DrawBuildingsD3D(); //struct BSPModel *DrawBuildingsSW(); //int OnOutdoorRedrawSW(); @@ -379,69 +367,60 @@ //void ExecOutdoorDrawSW(); void ChangeBetweenWinFullscreenModes(); void DrawBillboardList_BLV(); - void __cdecl sub_4A19B0(); bool AreRenderSurfacesOk(); bool IsGammaSupported(); void SaveScreenshot(const char *pFilename, unsigned int width, unsigned int height); void PackScreenshot(unsigned int width, unsigned int height, void *out_data, unsigned int data_size, unsigned int *screenshot_size); + int _46A6AC_spell_render_d3d(int a1, int a2, int a3); + + void BeginLightmaps(); + void EndLightmaps(); + void BeginLightmaps2(); + void EndLightmaps2(); + bool DrawLightmap(struct Lightmap *pLightmap, struct Vec3_float_ *pColorMult, float z_bias); + + void BeginDecals(); + void EndDecals(); + void DrawDecal(struct Decal *pDecal, float z_bias); + + void do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, signed int sDiffuseBegin, const RenderVertexD3D3 *pLineEnd, signed int sDiffuseEnd, float z_stuff); + void DrawLines(const RenderVertexD3D3 *vertices, unsigned int num_vertices); + void DrawFansTransparent(const RenderVertexD3D3 *vertices, unsigned int num_vertices); + void DrawSpecialEffectsQuad(const RenderVertexD3D3 *vertices, IDirect3DTexture2 *texture); void am_Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3); void am_Blt_Chroma(RECT *pSrcRect, POINT *pTargetPoint, int a3, int blend_mode); - protected: - //unsigned int bUserDirect3D; - //unsigned int bStartInWindow; - unsigned int uDesiredDirect3DDevice; - //unsigned int uAcquiredDirect3DDevice; - //int field_10; - //int field_14; - //int field_18_locked_pitch; - public: int raster_clip_x; - public: int raster_clip_y; // clipping rect for raster ops - public: int raster_clip_z; // like RasterLine2D for (mini)map - public: int raster_clip_w; - //__int16 unused_2C[65536]; - //__int16 unused_2002C[65536]; - //int field_4002C; - //int field_40030; - int *pActiveZBuffer; - int *pDefaultZBuffer; - //int field_4003C; - //int field_40040; - //int field_40044; - //int field_40048; - //int field_4004C; - //HWND hWnd; - OSWindow *window; - //int field_40054; - unsigned int bWindowMode; - //int field_4005C[11]; - public: RenderD3D *pRenderD3D; + + protected: unsigned int uDesiredDirect3DDevice; + protected: int raster_clip_x; + protected: int raster_clip_y; // clipping rect for raster ops + protected: int raster_clip_z; // like RasterLine2D for (mini)map + protected: int raster_clip_w; + public: int *pActiveZBuffer; + protected: int *pDefaultZBuffer; + protected: OSWindow *window; + protected: unsigned int bWindowMode; + protected: RenderD3D *pRenderD3D; public: IDirectDraw4 *pDirectDraw4; public: IDirectDrawSurface4 *pFrontBuffer4; public: IDirectDrawSurface4 *pBackBuffer4; - //IDirectDrawSurface4 *pColorKeySurface4; - //IDirectDraw2 *pDirectDraw2; - //IDirectDrawSurface2 *pFrontBuffer2; - //IDirectDrawSurface2 *pBackBuffer2; - //IDirectDrawSurface2 *pSomeSurface2; protected: DDPIXELFORMAT ddpfPrimarySuface; - public: unsigned int uTargetRBits; - public: unsigned int uTargetGBits; - public: unsigned int uTargetBBits; - public: unsigned int uTargetRMask; - public: unsigned int uTargetGMask; - public: unsigned int uTargetBMask; + protected: unsigned int uTargetRBits; + protected: unsigned int uTargetGBits; + protected: unsigned int uTargetBBits; + protected: unsigned int uTargetRMask; + protected: unsigned int uTargetGMask; + protected: unsigned int uTargetBMask; protected: unsigned int uNumSceneBegins; protected: unsigned __int32 *pTargetSurface_unaligned; - public: void *pTargetSurface; + public: void *pTargetSurface; public: unsigned int uTargetSurfacePitch; - public: unsigned int uClipY; - public: unsigned int uClipX; - public: unsigned int uClipW; - public: unsigned int uClipZ; - public: unsigned int bClip; - //unsigned int bColorKeySupported; + protected: unsigned int uClipY; + protected: unsigned int uClipX; + protected: unsigned int uClipW; + protected: unsigned int uClipZ; + protected: unsigned int bClip; protected: unsigned int uNumD3DSceneBegins; protected: int using_software_screen_buffer; protected: RenderHWLContainer pD3DBitmaps; @@ -452,28 +431,16 @@ protected: unsigned int uLevelOfDetail; protected: unsigned int uMaxDeviceTextureDim; protected: unsigned int uMinDeviceTextureDim; - //int field_10365C; public: unsigned int bUsingSpecular; public: uint32_t uFogColor; - //int field_103668; public: unsigned int pHDWaterBitmapIDs[7]; - //char field_103688[32]; public: int hd_water_current_frame; public: int hd_water_tile_id; - //protected: IDirectDrawSurface4 *pSurface; - //protected: IDirect3DTexture2 *pTexture; - //int field_1036B8; - //int _gpu_memory_used; - public: void ( *pBeforePresentFunction)(); - //int field_1036C4; + public: void (*pBeforePresentFunction)(); public: uint32_t bFogEnabled; - //int field_1036CC; public: RenderBillboardD3D pBillboardRenderListD3D[1000]; public: unsigned int uNumBillboardsToDraw; - //int field_129834; - //unsigned int uCurrentlyLockedSurfacePitch; - //unsigned __int16 *pCurrentlyLockedSurfaceDataPtr; - //void *pCurrentlyLockedSoftSurface; + protected: void DoRenderBillboards_D3D(); @@ -481,6 +448,20 @@ void DrawBorderTiles(struct Polygon *poly); unsigned short *MakeScreenshot(signed int width, signed int height); bool CheckTextureStages(); + void ParseTargetPixelFormat(); + void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard); + void CreateDirectDraw(); + void SetDirectDrawCooperationMode(HWND hWnd, bool bFullscreen); + void SetDirectDrawDisplayMode(unsigned int uWidth, unsigned int uHeight, unsigned int uBPP); + void CreateFrontBuffer(); + void CreateBackBuffer(); + void CreateDirectDrawPrimarySurface(); + void CreateClipper(HWND a2); + void PackPCXpicture(unsigned short* picture_data, int wight, int heidth, void *data_buff, int max_buff_size,unsigned int* packed_size); + void SavePCXImage(const char *Filename, unsigned short* picture_data, int width, int height); + unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z); + unsigned int GetParentBillboardID(unsigned int uBillboardID); + unsigned int GetBillboardDrawListSize(); public: inline void WritePixel16(int x, int y, unsigned __int16 color)
--- a/UI/Books/UIMapBook.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/UI/Books/UIMapBook.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -528,8 +528,8 @@ v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->uMapBookMapZoom) >> 16) + screenCenter_X; v97 = (const void *)((unsigned __int64)(screenHeight * (signed __int64)viewparams->uMapBookMapZoom) >> 16); v55 = screenCenterY - (int)v97; - if ( v54 >= pRenderer->raster_clip_x && v54 <= pRenderer->raster_clip_z - && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w ) + //if ( v54 >= pRenderer->raster_clip_x && v54 <= pRenderer->raster_clip_z + // && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w ) { if ( viewparams->uMapBookMapZoom > 512 ) {
--- a/UI/UIOptions.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/UI/UIOptions.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -153,7 +153,7 @@ GUIWindow msg_window; // [sp+8h] [bp-54h]@3 pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(optvid_base_texture_id));//draw base texture - if ( !pRenderer->bWindowMode && pRenderer->IsGammaSupported() ) + //if ( !pRenderer->bWindowMode && pRenderer->IsGammaSupported() ) { pRenderer->DrawTextureIndexed(17 * uGammaPos + 42, 162, pIcons_LOD->GetTexture(pTextureIDs_GammaPositions[uGammaPos])); pRenderer->DrawTextureRGB(274, 169, &stru_506E40);//review_window @@ -166,13 +166,13 @@ msg_window.DrawTitleText(pFontSmallnum, 0, 0, ui_gamemenu_video_gamma_title_color, pGlobalTXT_LocalizationStrings[226], 3); // "Gamma controls the relative ""brightness"" of the game. May vary depending on your monitor." } - if (!pRenderer->pRenderD3D)//if software + /*if (!pRenderer->pRenderD3D) { pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(not_available_bloodsplats_texture_id)); pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(not_available_us_colored_lights_texture_id)); pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(not_available_tinting_texture_id)); } - else + else*/ { if (pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(bloodsplats_texture_id));
--- a/UI/UIPopup.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/UI/UIPopup.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -527,7 +527,7 @@ pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, Color16(0xE1u, 255, 0x9Bu));//горизонтальная нижняя линия pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));//левая вертикальная линия pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportW + 1, Color16(0xE1u, 255, 0x9Bu));//правая вертикальная линия - if ( pRenderer->pRenderD3D ) + //if ( pRenderer->pRenderD3D ) { v106.uScreenSpaceY = v115 + v106.uViewportY + pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].uBufferHeight; memset(&Dst, 0, 0x64u); @@ -558,14 +558,14 @@ dst_z = v106.uViewportZ; if (dst_w > v106.uViewportW) dst_w = v106.uViewportW; - pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask); - pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask); + pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0x7FF); + pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0x7FF); v84.left = v106.uViewportX; v84.top = v106.uViewportY; v84.right = v106.uViewportZ; v84.bottom = v106.uViewportW; ErrD3D(pRenderer->pBackBuffer4->Blt(&v84, 0, 0, 16778240u, &Dst)); - if ( pRenderer->uTargetGBits == 5 ) + /*if ( pRenderer->uTargetGBits == 5 ) { __debugbreak(); // no monster popup for r5g5b5 will be memset(&pDesc, 0, 0x7Cu); @@ -612,7 +612,7 @@ pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]].pTextureSurface->Unlock(0); } } - else + else*/ { memset(&pDesc, 0, 0x7Cu); pDesc.dwSize = 124; @@ -640,12 +640,12 @@ } } } - else + /*else { pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0); if ( v10->pHwSpriteIDs[0] >= 0 ) pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]].DrawSprite_sw(&v106, 0); - } + }*/ //name and profession if ( pActors[uActorID].sNPC_ID ) { @@ -1309,7 +1309,7 @@ { pMouse->GetClickPos(&pX, &pY); } - if ( pRenderer->bWindowMode ) + //if ( pRenderer->bWindowMode ) { GetCursorPos(&Point); ScreenToClient(window->GetApiHandle(), &Point); @@ -1428,10 +1428,10 @@ if ( (signed int)pX <= 320 ) popup_window.uFrameX = pX + 30; popup_window.uFrameY = 40; - if ( pRenderer->pRenderD3D ) - LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val(); - else - v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; + //if ( pRenderer->pRenderD3D ) + v5 = pGame->pVisInstance->get_picked_object_zbuf_val(); + /*else + v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/ if (PID_TYPE((unsigned __int16)v5) == OBJECT_Actor) { /*if ( pRenderer->uNumSceneBegins )
--- a/UI/UiGame.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/UI/UiGame.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -1139,7 +1139,7 @@ } // 5C35BC: using guessed type int bForceDrawFooter; //----- (00420EFF) -------------------------------------------------------- -void GameUI_WritePointedObjectStatusString() +void GameUI_WritePointedObjectStatusString() { int v1; // ebx@6 GUIWindow *pWindow; // edi@7 @@ -1173,7 +1173,7 @@ //окно(область) игры---------------------------------- if ( pCurrentScreen == SCREEN_GAME ) { - if ( pRenderer->pRenderD3D ) // inlined mm8::4C1E01 + //if ( pRenderer->pRenderD3D ) // inlined mm8::4C1E01 { v18 = pGame->pVisInstance->get_picked_object_zbuf_val(); if ( pX < (unsigned int)pViewport->uScreen_TL_X || pX > (unsigned int)pViewport->uScreen_BR_X @@ -1194,8 +1194,8 @@ return; } } - else - v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; + /*else + v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/ pMouse->uPointingObjectID = (unsigned __int16)v18; v19 = (signed)PID_ID(v18); //For Items------------------------------------ @@ -1663,10 +1663,10 @@ v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, v0)->uTextureID); else v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, 0)->uTextureID); - if ( pRenderer->pRenderD3D ) + //if ( pRenderer->pRenderD3D ) pRenderer->DrawTextureIndexed(8, 8, v7); - else - pRenderer->DrawTextureTransparent(8, 8, v7); + /*else + pRenderer->DrawTextureTransparent(8, 8, v7);*/ } if ( pParty->WaterWalkActive() ) { @@ -1674,10 +1674,10 @@ v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, v0)->uTextureID); else v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, 0)->uTextureID); - if ( pRenderer->pRenderD3D ) + //if ( pRenderer->pRenderD3D ) pRenderer->DrawTextureIndexed(396, 8, v9); - else - pRenderer->DrawTextureTransparent(396, 8, v9); + /*else + pRenderer->DrawTextureTransparent(396, 8, v9);*/ } } for (uint i = 0; i < 4; ++i) @@ -1719,7 +1719,7 @@ { pPortrait = pTexture_PlayerFaceEradicated; if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) - pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); + pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); else pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime @@ -1732,7 +1732,7 @@ { pPortrait = pTexture_PlayerFaceDead; if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) - pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); + pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); else pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime @@ -1759,7 +1759,7 @@ pPlayer->field_1AA2 = pFrame->uTextureID - 1; pPortrait = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID]; if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) - pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); + pRenderer->DrawTranslucent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); else pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime @@ -2042,8 +2042,8 @@ //if (uWizardEyeSkillLevel == 1 pPoint_X = uCenterX + ((unsigned __int64)((pSpriteObjects[i].vPosition.x - pParty->vPosition.x) * (signed __int64)uZoom) >> 16); pPoint_Y = uCenterY - ((signed __int64)((pSpriteObjects[i].vPosition.y - pParty->vPosition.y) * (signed __int64)uZoom) >> 16); - if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z && - pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w) + //if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z && + // pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w) { if (pObjectList->pObjects[pSpriteObjects[i].uObjectDescID].uFlags & OBJECT_DESC_UNPICKABLE) { @@ -2072,8 +2072,8 @@ { pPoint_X = uCenterX + ((unsigned __int64)(( pActors[i].vPosition.x - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16); pPoint_Y = uCenterY - ((unsigned __int64)(( pActors[i].vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16); - if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z - && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w ) + //if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z + // && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w ) { pColor = ui_game_minimap_actor_friendly_color; if ( BYTE3(pActors[i].uAttributes) & 1 ) @@ -2102,8 +2102,8 @@ { pPoint_X = uCenterX + ((unsigned __int64)((pLevelDecorations[i].vPosition.x - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16); pPoint_Y = uCenterY - ((unsigned __int64)((pLevelDecorations[i].vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16); - if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z - && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w ) + //if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z + // && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w ) { if ( (signed int)uZoom > 512 ) {
--- a/_deleted.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/_deleted.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -14575,4 +14575,73 @@ } } + +//----- (0046A6AC) -------------------------------------------------------- +int __fastcall _46A6AC_spell_render(int a1, int a2, int a3) +{ + int result; // eax@2 + int *v5; // esi@6 + unsigned int v6; // ebx@6 + signed int v7; // edi@9 + int i; // eax@14 + int v10; // ecx@19 + unsigned int v13; // [sp+8h] [bp-10h]@4 + int *v15; // [sp+10h] [bp-8h]@4 + int v16; // [sp+14h] [bp-4h]@3 + + if ( pRenderer->pRenderD3D ) + { + result = _46A6AC_spell_render_d3d(a1, a2, a3); + } + else + { + __debugbreak(); // SW render never called + v16 = 0; + if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) + { + v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; + v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1; + for ( v13; v13; --v13 ) + { + if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X ) + { + v5 = v15; + v6 = ((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X - 1) >> 1) + 1; + for ( v6; v6; --v6 ) + { + if ( PID_TYPE(*(char *)v5) == OBJECT_Actor) + { + if ( *v5 <= a3 << 16 ) + { + v7 = PID_ID((signed int)(unsigned __int16)*v5); + if ( pActors[v7].uAIState != Dead && pActors[v7].uAIState != Dying && pActors[v7].uAIState != Removed + && pActors[v7].uAIState != Summoned && pActors[v7].uAIState != Disabled ) + { + for ( i = 0; i < v16; ++i ) + { + if ( *(int *)(a1 + 4 * i) == v7 ) + break; + } + if ( i == v16 ) + { + if ( i < a2 - 1 ) + { + v10 = v16++; + *(int *)(a1 + 4 * v10) = v7; + } + } + } + } + } + v5 += 2; + } + } + v15 += 1280; + } + } + result = v16; + } + return result; +} + */ \ No newline at end of file
--- a/mm7_2.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/mm7_2.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -447,7 +447,7 @@ pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, - pRenderer->uTargetGMask | pRenderer->uTargetBMask); + 0x7FF); Texture* pTex = pIcons_LOD->GetTexture(uTextureID_Leather); pRenderer->GetLeather(8, 352 - v0, pTex, pTex->uTextureHeight - v0); @@ -3090,7 +3090,7 @@ SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); pGame->Deinitialize(); - pRenderer->Release2(); + pRenderer->Release(); delete window; //if ( !DestroyWindow(hWnd) ) // GetLastError(); @@ -4555,118 +4555,6 @@ } -//----- (0046A6AC) -------------------------------------------------------- -int __fastcall _46A6AC_spell_render(int a1, int a2, int a3) -{ - int result; // eax@2 - int *v5; // esi@6 - unsigned int v6; // ebx@6 - signed int v7; // edi@9 - int i; // eax@14 - int v10; // ecx@19 - unsigned int v13; // [sp+8h] [bp-10h]@4 - int *v15; // [sp+10h] [bp-8h]@4 - int v16; // [sp+14h] [bp-4h]@3 - - //if ( pRenderer->pRenderD3D ) - { - result = _46A6AC_spell_render_d3d(a1, a2, a3); - } - /*else - { - __debugbreak(); // SW render never called - v16 = 0; - if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) - { - v15 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; - v13 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1; - for ( v13; v13; --v13 ) - { - if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X ) - { - v5 = v15; - v6 = ((viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X - 1) >> 1) + 1; - for ( v6; v6; --v6 ) - { - if ( PID_TYPE(*(char *)v5) == OBJECT_Actor) - { - if ( *v5 <= a3 << 16 ) - { - v7 = PID_ID((signed int)(unsigned __int16)*v5); - if ( pActors[v7].uAIState != Dead && pActors[v7].uAIState != Dying && pActors[v7].uAIState != Removed - && pActors[v7].uAIState != Summoned && pActors[v7].uAIState != Disabled ) - { - for ( i = 0; i < v16; ++i ) - { - if ( *(int *)(a1 + 4 * i) == v7 ) - break; - } - if ( i == v16 ) - { - if ( i < a2 - 1 ) - { - v10 = v16++; - *(int *)(a1 + 4 * v10) = v7; - } - } - } - } - } - v5 += 2; - } - } - v15 += 1280; - } - } - result = v16; - }*/ - return result; -} - -//----- (0046A7C8) -------------------------------------------------------- -int __fastcall _46A6AC_spell_render_d3d(int a1, int a2, int a3) -{ - unsigned int v3; // eax@2 - unsigned int v5; // eax@2 - unsigned int v6; // eax@4 - int v10; // ecx@11 - unsigned int v12; // [sp+10h] [bp-14h]@1 - int v15; // [sp+1Ch] [bp-8h]@1 - unsigned int a1a; // [sp+20h] [bp-4h]@1 - - v15 = 0; - v12 = pRenderer->GetBillboardDrawListSize(); - if ( (signed int)pRenderer->GetBillboardDrawListSize() > 0 ) - { - for ( a1a = 0; (signed int)a1a < (signed int)v12; ++a1a ) - { - v3 = pRenderer->GetParentBillboardID(a1a); - v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; - if ( PID_TYPE(v5) == OBJECT_Actor) - { - if ( pBillboardRenderList[v3].sZValue <= (unsigned int)(a3 << 16) ) - { - v6 = PID_ID(v5); - if ( pActors[v6].uAIState != Dead && pActors[v6].uAIState != Dying && pActors[v6].uAIState != Removed - && pActors[v6].uAIState != Disabled && pActors[v6].uAIState != Summoned ) - { - if ( pGame->pVisInstance->DoesRayIntersectBillboard((double)a3, a1a) ) - { - if ( v15 < a2 - 1 ) - { - __debugbreak();// *(int *)(a1 + 4 * v10) = v6; что это такое? - v10 = v15++; - *(int *)(a1 + 4 * v10) = v6; - } - } - } - } - } - } - } - return v15; -} - //----- (0046A89E) -------------------------------------------------------- int __fastcall _46A89E_immolation_effect(int a1, int a2, int a3) {
--- a/mm7_3.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/mm7_3.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -2507,11 +2507,12 @@ memcpy(&v[5], &v[1], sizeof(*v)); + __debugbreak(); + /* pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); pRenderer->pRenderD3D->pDevice->SetTexture(0, skybox_texture); pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v, 6, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); - //pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, v + 1, 3, D3DDP_DONOTUPDATEEXTENTS | D3DDP_DONOTLIGHT); - +*/ return true; }
--- a/mm7_4.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/mm7_4.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -249,7 +249,7 @@ // 4ED498: using guessed type char byte_4ED498; //----- (00493938) -------------------------------------------------------- -void _493938_regenerate() +void _493938_regenerate() { int current_time; // edi@1 int last_reg_time; // qax@1 @@ -275,7 +275,7 @@ int v27; // eax@36 int v28; // eax@37 signed int v31; // ecx@53 - char v41[400]; // [sp+4h] [bp-22Ch]@20 + int v41[100]; // [sp+4h] [bp-22Ch]@20 SpriteObject a1; // [sp+194h] [bp-9Ch]@15 Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15 bool has_dragon_flag; // [sp+210h] [bp-20h]@22 @@ -372,7 +372,7 @@ v13 = _46A89E_immolation_effect((int)v41, 100, 307); for ( v9 = 0; v9 < v13; ++v9 ) { - v14 = (unsigned int *)&v41[4 * v9]; + v14 = (unsigned int *)&v41[v9]; v15 = *v14; v16 = *v14; a1.vPosition.x = pActors[v16].vPosition.x; @@ -422,13 +422,13 @@ { v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType; if ( v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc") - && v25 == 44 //of Life("HP (+10), Regen hpts") - && v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && - && v25 == 54 )// of The Troll("End (+15), Regen hpts") + || v25 == 44 //of Life("HP (+10), Regen hpts") + || v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && + || v25 == 54 )// of The Troll("End (+15), Regen hpts") recovery_HP = true; if ( v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc") - && v25 == 47 //of The Eclipse("SP (+10), Regen spts") - && v25 == 55 )//of The Unicorn("Luck (+15), Regen spts") + || v25 == 47 //of The Eclipse("SP (+10), Regen spts") + || v25 == 55 )//of The Unicorn("Luck (+15), Regen spts") recovery_SP = true; if ( v25 == 66 )// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.") { @@ -437,27 +437,29 @@ } } - if ( recovery_HP && !pParty->pPlayers[v49].pConditions[Condition_Dead] - && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) + if (recovery_HP && + !pParty->pPlayers[v49].pConditions[Condition_Dead] && + !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) { - ++pParty->pPlayers[v49].sHealth; - if ( pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() ) - pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth(); + if ( pParty->pPlayers[v49].sHealth < pParty->pPlayers[v49].GetMaxHealth() ) + ++pParty->pPlayers[v49].sHealth; if ( pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0 ) pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; redraw_flag = true; } - if ( recovery_SP ) + if (recovery_SP && + !pParty->pPlayers[v49].pConditions[Condition_Dead] && + !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) { - ++pParty->pPlayers[v49].sMana; - if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() ) - pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana(); + if ( pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana() ) + ++pParty->pPlayers[v49].sMana; redraw_flag = true; } - if ( decrease_HP && !pParty->pPlayers[v49].pConditions[Condition_Dead] - && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) + if (decrease_HP && + !pParty->pPlayers[v49].pConditions[Condition_Dead] && + !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) { --pParty->pPlayers[v49].sHealth; if ( !(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0 ) @@ -494,9 +496,8 @@ //for warlock if ( has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK ) { - ++pParty->pPlayers[v49].sMana; - if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() ) - pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana(); + if ( pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana() ) + ++pParty->pPlayers[v49].sMana; redraw_flag = true; } @@ -520,9 +521,8 @@ } if ( lich_jar_flag ) { - ++pParty->pPlayers[v49].sMana; - if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() ) - pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana(); + if ( pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana() ) + ++pParty->pPlayers[v49].sMana; } //for zombie
--- a/mm7_unsorted_subs.h Thu Jan 09 14:36:48 2014 +0200 +++ b/mm7_unsorted_subs.h Thu Jan 09 17:29:17 2014 +0200 @@ -218,7 +218,6 @@ int __fastcall sub_4AAEA6_transform(struct RenderVertexSoft *a1); int __fastcall sub_4AB66C(int, int); // weak int GetSoundStrengthByDistanceFromParty(int x, int y, int z); -struct _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void); void PlayLevelMusic(); unsigned int __fastcall sub_4B0E07(unsigned int uFaceID); // idb void sub_4B1447_party_fine(int a1, int a2, int a3); @@ -226,10 +225,7 @@ void ShowPopupShopItem(); void RestAndHeal(__int64 uNumMinutes); // idb void GetHouseGoodbyeSpeech(); -int __fastcall _46A6AC_spell_render(int a1, int a2, int a3); -int __fastcall _46A6AC_spell_render_d3d(int a1, int a2, int a3); int __fastcall _46A89E_immolation_effect(int a1, int a2, int a3); -int sub_46A99B(); unsigned int GetGravityStrength(); void UpdateUserInput_and_MapSpecificStuff(); void BLV_UpdateUserInputAndOther();
--- a/stru6.cpp Thu Jan 09 14:36:48 2014 +0200 +++ b/stru6.cpp Thu Jan 09 17:29:17 2014 +0200 @@ -1417,7 +1417,7 @@ void stru6::FadeScreen__like_Turn_Undead_and_mb_Armageddon(unsigned int uDiffuseColor, unsigned int uFadeTime) { this->uFadeTime = uFadeTime; - this->uFadeTime2 = uFadeTime; + this->uFadeLength = uFadeTime; this->uFadeColor = uDiffuseColor; } @@ -1433,7 +1433,7 @@ { double v4; // st7@4 double v5; // st6@4 - double v6; // st7@4 + //double v6; // st7@4 float v7; // ST14_4@6 unsigned int v8; // ST14_4@8 unsigned int v9; // eax@8 @@ -1461,16 +1461,15 @@ } field_204 = 0; - v26 = uFadeTime; - if ( v26 > 0 ) + if ( uFadeTime > 0 ) { - v4 = (double)(signed int)v26 / (double)uFadeTime2; + v4 = (double)uFadeTime / (double)uFadeLength; v5 = 1.0 - v4 * v4; - v6 = v5; + //v6 = v5; if ( v5 > 0.9 ) - v6 = 1.0 - (v5 - 0.9) * 10.0; - v7 = v6; - pRenderer->_4A52F1(uFadeColor, v7); + v5 = 1.0 - (v5 - 0.9) * 10.0; + v7 = v5; + pRenderer->ScreenFade(uFadeColor, v7); uFadeTime -= pEventTimer->uTimeElapsed; } @@ -1523,24 +1522,8 @@ vd3d[1].texcoord.y = 1.0; vd3d[2].texcoord.y = 1.0; vd3d[3].texcoord.y = 0.0; - pRenderer->pRenderD3D->pDevice->SetTexture( - 0, - pSprites_LOD->pHardwareSprites[v11].pTexture); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_ALWAYS); - pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, vd3d, 4, 28); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE); - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZFUNC, D3DCMP_LESS); + + pRenderer->DrawSpecialEffectsQuad(vd3d, pSprites_LOD->pHardwareSprites[v11].pTexture); } /*else {