Mercurial > might-and-magic-trilogy
diff mm7_4.cpp @ 45:bcc051713d20
BLV render & seffects
author | Nomad |
---|---|
date | Mon, 22 Oct 2012 20:45:14 +0200 |
parents | 484492a6dd28 |
children | 79a30ee1ecdb |
line wrap: on
line diff
--- a/mm7_4.cpp Sun Oct 21 23:26:23 2012 +0600 +++ b/mm7_4.cpp Mon Oct 22 20:45:14 2012 +0200 @@ -7132,109 +7132,9 @@ } -//----- (004A1C1E) -------------------------------------------------------- -void __cdecl DoRenderBillboards_D3D() -{ - signed int v0; // ebp@1 - signed int *v1; // esi@2 - //IDirect3DDevice3Vtbl *v2; // esi@7 - unsigned int v3; // eax@7 - unsigned int v4; // [sp+58h] [bp-4h]@2 - - v0 = -1; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u)); - if ( ((pRenderer->uNumBillboardsToDraw - 1) & 0x80000000u) == 0 ) - { - v1 = (signed int *)&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - 1].bOpaque; - v4 = pRenderer->uNumBillboardsToDraw; - do - { - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture( - 0, - (IDirect3DTexture2 *)*(v1 - 35))); - if ( *v1 != v0 ) - { - v0 = *v1; - SetBillboardBlendOptions(*v1); - } - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( - D3DPT_TRIANGLEFAN, - 452, - v1 - 33, - *(v1 - 34), - 24)); - v1 -= 39; - --v4; - } - while ( v4 ); - } - if ( pRenderer->turnFogOn ) - { - pRenderer->turnFogOn = 0; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u)); - //v2 = pRenderer->pRenderD3D->pDevice->lpVtbl; - v3 = GetLevelFogColor(); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v3 & 0xFFFFFF)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); - } - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u)); -} - -//----- (004A1DA8) -------------------------------------------------------- -void __fastcall SetBillboardBlendOptions(signed int a1) -{ - //IDirect3DDevice3Vtbl *v1; // edi@9 - unsigned int v2; // eax@9 - int v3; // [sp+0h] [bp-4h]@0 - - if ( !a1 ) - { - if ( pRenderer->turnFogOn ) - { - pRenderer->turnFogOn = 0; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u)); - //v1 = pRenderer->pRenderD3D->pDevice->lpVtbl; - v2 = GetLevelFogColor(); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v2 & 0xFFFFFF)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); - } - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1)); - return; - } - if ( a1 > 0 && a1 <= 3 ) - { - if ( pRenderer->bUsingSpecular ) - { - if ( !pRenderer->turnFogOn ) - { - pRenderer->turnFogOn = 1; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0)); - } - } - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u)); - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0)); - } -} - - - - - - //----- (004A46E6) -------------------------------------------------------- -int __fastcall sub_4A46E6(unsigned int x, signed int y, signed int a3, int a4, unsigned int a5) +int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor) { int v5; // eax@1 int z; // eax@1 @@ -7257,7 +7157,7 @@ signed int v23; // [sp+20h] [bp+Ch]@1 v5 = a4; - v23 = a3 >> 16; + v23 = _z >> 16; z = x + v5; if ( z >= (signed int)pViewport->uViewportX && (signed int)x <= (signed int)pViewport->uViewportZ @@ -7271,12 +7171,12 @@ pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch]; v22 = z - x; pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y]; - v7 = a5 >> 3; - v8 = a5 & 0xF0; + v7 = lightColor >> 3; + v8 = lightColor & 0xF0; v9 = v7 & 0x1E0000; if ( pRenderer->uTargetGBits == 5 ) { - v10 = (v8 | (((unsigned __int16)(a5 & 0xF000) | (unsigned int)v9) >> 3)) >> 4; + v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4; v11 = (int *)pTarget; v12 = pTargetZ; v13 = v22; @@ -7323,7 +7223,7 @@ } else { - v15 = (v8 | (((unsigned __int16)(a5 & 0xF800) | (unsigned int)v9) >> 2)) >> 4; + v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4; v16 = (int *)pTarget; v17 = pTargetZ; v18 = v22; @@ -13447,7 +13347,7 @@ ++pMessageQueue_50CBD0->uNumMessages; } if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) - pDialogue_SpeakingActor->uAIState = 11; + pDialogue_SpeakingActor->uAIState = Removed; if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(61, 0); goto LABEL_87; @@ -15172,7 +15072,7 @@ { v4->uCurrentActionTime = 0; v4->uCurrentActionLength = 0; - v4->uAIState = 5; + v4->uAIState = Dead; v4->UpdateAnimation(); } v1 = v18; @@ -15249,11 +15149,9 @@ //----- (0043FDED) -------------------------------------------------------- -unsigned int __cdecl PrepareActorRenderList_BLV() +void PrepareActorRenderList_BLV() { RenderBillboard *v0; // esi@0 - unsigned int result; // eax@1 - char *v2; // edi@2 unsigned __int16 v3; // ax@3 unsigned int v4; // eax@5 unsigned __int16 v5; // cx@5 @@ -15264,7 +15162,6 @@ SpriteFrame *v10; // ebx@18 int *v11; // eax@18 int v12; // ecx@28 - Actor *v13; // ecx@35 IndoorCameraD3D **v14; // eax@36 double v15; // st7@36 float v16; // eax@36 @@ -15290,8 +15187,6 @@ __int16 a5; // [sp+2Ch] [bp-28h]@5 int a5a; // [sp+2Ch] [bp-28h]@36 int a5b; // [sp+2Ch] [bp-28h]@40 - unsigned int v39; // [sp+30h] [bp-24h]@1 - int v40; // [sp+34h] [bp-20h]@2 __int16 v41; // [sp+3Ch] [bp-18h]@18 int a6; // [sp+40h] [bp-14h]@34 int v43; // [sp+44h] [bp-10h]@34 @@ -15299,36 +15194,21 @@ signed int y; // [sp+4Ch] [bp-8h]@32 int x; // [sp+50h] [bp-4h]@32 - result = 0; - v39 = 0; - if ( (signed int)uNumActors > 0 ) - { - v40 = 0; - v2 = (char *)&pActors[0].uAttributes; - while ( 1 ) - { - v3 = *((_WORD *)v2 + 70); - *(_DWORD *)v2 &= 0xFFFFFFF7u; - if ( v3 != 11 ) - { - if ( v3 != 19 ) - break; - } -LABEL_48: - ++v39; - v40 += 32; - result = v39; - v2 += 836; - if ( (signed int)v39 >= (signed int)uNumActors ) - return result; - } - a5 = *((_WORD *)v2 + 61); - a2 = *((_WORD *)v2 + 54); - a1a = *((_WORD *)v2 + 53); - a3 = *((_WORD *)v2 + 55); + for (uint i = 0; i < uNumActors; ++i) + { + auto p = pActors + i; + + if (p->uAIState == Removed || + p->uAIState == Disabled) + continue; + + a5 = p->uSectorID; + a2 = p->vPosition.y; + a1a = p->vPosition.x; + a3 = p->vPosition.z; v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); - LOWORD(v0) = *((_WORD *)v2 + 59); - v5 = *((_WORD *)v2 + 71); + LOWORD(v0) = p->uYawAngle; + v5 = p->uCurrentActionAnimation; v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7; v32 = v6; if ( pParty->bTurnBasedModeOn ) @@ -15345,16 +15225,16 @@ { v7 = pBLVRenderParams->field_0_timer_; LABEL_10: - v8 = v40 + v7; + v8 = i * 32 + v7; goto LABEL_12; } } - v8 = *((_DWORD *)v2 + 37); + v8 = p->uCurrentActionTime; LABEL_12: - if ( *((_QWORD *)v2 + 32) > 0i64 || *((_QWORD *)v2 + 34) > 0i64 ) + if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 ) v8 = 0; - v31 = *(_WORD *)&v2[2 * (signed __int16)v5 + 152]; - if ( *((_WORD *)v2 + 70) == 16 ) + v31 = p->pSpriteIDs[v5]; + if (p->uAIState == 16 ) v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8); else v9 = pSpriteFrameTable->GetFrame(v31, v8); @@ -15386,25 +15266,24 @@ } v12 = 0; if ( pStru170->field_53730 <= 0 ) - goto LABEL_48; - while ( pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != *((_WORD *)v2 + 61) ) + continue; + while (pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != p->uSectorID) { ++v12; if ( v12 >= pStru170->field_53730 ) - goto LABEL_48; + continue; } if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1) || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) ) - goto LABEL_48; + continue; pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6); - result = uNumBillboardsToDraw; + v0 = &pBillboardRenderList[uNumBillboardsToDraw]; - if ( (signed int)uNumBillboardsToDraw >= 500 ) - return result; + if (uNumBillboardsToDraw >= 500) + break; ++uNumBillboardsToDraw; ++uNumSpritesDrawnThisFrame; - v13 = (Actor *)(v2 - 36); - *(_DWORD *)v2 |= 8u; + p->uAttributes |= 8u; v29 = pRenderer->pRenderD3D == 0; v0->uHwSpriteID = v10->pHwSpriteIDs[v32]; v0->uPalette = v10->uPaletteIndex; @@ -15432,21 +15311,21 @@ a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; } v0->field_4 = a5a; - if ( (signed __int64)v13->pActorBuffs[3].uExpireTime <= 0 ) - { - if ( (signed __int64)v13->pActorBuffs[10].uExpireTime > 0 ) - { - a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F((Actor *)(v2 - 36)) * (signed __int64)v0->field_4) >> 16; + if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 ) + { + if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 ) + { + a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->field_4) >> 16; goto LABEL_43; } } else { - v22 = v13->pActorBuffs[3].uPower; + v22 = p->pActorBuffs[3].uPower; if ( v22 ) { v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16; - v24 = *((_WORD *)v2 + 116); + v24 = p->pActorBuffs[3].uPower; v0->field_0 = v23; a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16; LABEL_43: @@ -15456,29 +15335,27 @@ } LABEL_44: HIWORD(v25) = HIWORD(x); - v0->field_20 = a1a; - v0->field_22 = a2; - v0->field_24 = a3; - v0->field_26 = v43; - v0->field_28 = a6; + v0->some_x = a1a; + v0->some_y = a2; + v0->some_z = a3; + v0->uScreenSpaceX = v43; + v0->uScreenSpaceY = a6; LOWORD(v25) = 0; LOBYTE(v26) = v41; - v0->sZValue = v25 + (8 * v39 | 3); + v0->sZValue = v25 + (8 * i | 3); v27 = pMonsterList->pMonsters; - v28 = *((_WORD *)v2 + 30); - v29 = *((_DWORD *)v2 + 65) == 0; - v30 = *((_DWORD *)v2 + 65) < 0; + v28 = p->pMonsterInfo.uID; + v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0; + v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0; v0->field_1E = v41; v0->pSpriteFrame = v10; - v0->field_2C_prolly_tint = *((_DWORD *)&v27[v28] - 36); - if ( !v30 && (!(v30 | v29) || *((_DWORD *)v2 + 64)) ) + v0->uTintColor = *((_DWORD *)&v27[v28] - 36); + if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) ) { HIBYTE(v26) = HIBYTE(v41) | 1; v0->field_1E = v26; } - goto LABEL_48; - } - return result; + } }