Mercurial > mm7
changeset 152:796b79187c27
Слияние
author | Ritor1 |
---|---|
date | Tue, 12 Feb 2013 15:28:36 +0600 |
parents | 9abdd40a107b (current diff) 8ab4484c22e0 (diff) |
children | 86a2637ba125 |
files | Render.cpp mm7_1.cpp mm7_3.cpp mm7_4.cpp |
diffstat | 10 files changed, 348 insertions(+), 354 deletions(-) [+] |
line wrap: on
line diff
--- a/LOD.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/LOD.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -569,12 +569,12 @@ v3 = a2; v78 = this; - result = a2->field_10; - v58 = a2->field_10; + result = a2->_screenspace_x_scaler_packedfloat; + v58 = a2->_screenspace_x_scaler_packedfloat; if ( result <= 0 ) return result; - v5 = a2->field_14; - v6 = a2->field_10; + v5 = a2->_screenspace_y_scaler_packedfloat; + v6 = a2->_screenspace_x_scaler_packedfloat; v87 = (signed __int64)0x100000000ui64 / result; v48 = (signed __int64)0x100000000ui64 / result; v62 = (signed __int64)0x100000000ui64 / v5;
--- a/Outdoor.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/Outdoor.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -138,7 +138,7 @@ PrepareActorsDrawList(); if (!pOutdoorCamera->bDoNotRenderDecorations) - pRenderer->DrawDecorations(); + pRenderer->PrepareDecorationsRenderList_ODM(); pRenderer->DrawLayingItems_Shooting_Magic_ODM(); pRenderer->TransformBillboardsAndSetPalettesODM();//Ritor1: do comment to test @@ -3116,19 +3116,19 @@ v28->uHwSpriteID = v15->pHwSpriteIDs[v41]; v28->uIndoorSectorID = 0; v28->uPalette = v15->uPaletteIndex; - v28->field_0 = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16; + v28->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16; v30 = HIDWORD(actor->pActorBuffs[3].uExpireTime) == 0; v31 = SHIDWORD(actor->pActorBuffs[3].uExpireTime) < 0; - v28->field_4 = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16; + v28->_screenspace_y_scaler_packedfloat = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16; if ( v31 || v31 | v30 && LODWORD(actor->pActorBuffs[3].uExpireTime) <= 0u ) { if ( (signed __int64)actor->pActorBuffs[10].uExpireTime > 0i64 ) { v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F(actor) - * (signed __int64)v28->field_4) >> 16; + * (signed __int64)v28->_screenspace_y_scaler_packedfloat) >> 16; LABEL_53: LOWORD(v27) = v43; - v28->field_4 = v52; + v28->_screenspace_y_scaler_packedfloat = v52; } } else @@ -3137,8 +3137,8 @@ if ( v32 ) { v33 = actor->pActorBuffs[3].uPower; - v28->field_0 = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->field_0) >> 16; - v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->field_4) >> 16; + v28->_screenspace_x_scaler_packedfloat = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->_screenspace_x_scaler_packedfloat) >> 16; + v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->_screenspace_y_scaler_packedfloat) >> 16; goto LABEL_53; } }
--- a/ParticleEngine.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/ParticleEngine.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -280,11 +280,11 @@ HIDWORD(v15) = pBLVRenderParams->field_40 >> 16; v16 = v15 / z; v17 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; - pParticle->field_58 = v16; + pParticle->_screenspace_scale = v16; uParticleID = (unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16; LODWORD(v18) = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v16 * (signed __int64)(a6 + v17)) >> 16) >> 16); - v19 = pParticle->field_58; + v19 = pParticle->_screenspace_scale; pParticle->uScreenSpaceZ = v18; uParticleID = (unsigned __int64)(v19 * (signed __int64)(HIDWORD(v13) + HIDWORD(a5))) >> 16; v20 = pBLVRenderParams->uViewportCenterY @@ -329,11 +329,11 @@ HIDWORD(v30) = pBLVRenderParams->field_40 >> 16; v31 = v30 / z; v32 = (unsigned __int64)(y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; - pParticle->field_58 = v31; + pParticle->_screenspace_scale = v31; uParticleID = (unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16; LODWORD(v33) = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v31 * (signed __int64)(v28 + v32)) >> 16) >> 16); - v34 = pParticle->field_58; + v34 = pParticle->_screenspace_scale; pParticle->uScreenSpaceZ = v33; v35 = pBLVRenderParams->uViewportCenterY - ((signed int)((unsigned __int64)(v34 * (signed __int64)v29) >> 16) >> 16); @@ -360,10 +360,10 @@ LODWORD(v40) = pBLVRenderParams->field_40 << 16; HIDWORD(v40) = pBLVRenderParams->field_40 >> 16; v41 = v40 / z; - pParticle->field_58 = v41; + pParticle->_screenspace_scale = v41; uParticleID = (unsigned __int64)(v41 * (signed __int64)a2) >> 16; v42 = pBLVRenderParams->uViewportCenterX - ((signed int)((unsigned __int64)(v41 * (signed __int64)a2) >> 16) >> 16); - v43 = pParticle->field_58; + v43 = pParticle->_screenspace_scale; pParticle->uScreenSpaceX = v42; v44 = v43 * (signed __int64)v24; uParticleID = v44 >> 16; @@ -372,9 +372,9 @@ v46 = pBLVRenderParams->uViewportCenterY - v44; pParticle->uScreenSpaceY = pBLVRenderParams->uViewportCenterY - v44; v47 = v45; - v48 = _48B561_mess_with_scaling_along_z(/*v46, */v47) * (signed __int64)pParticle->field_58; + v48 = _48B561_mess_with_scaling_along_z(/*v46, */v47) * (signed __int64)pParticle->_screenspace_scale; uParticleID = v48 >> 16; - pParticle->field_58 = v48 >> 16; + pParticle->_screenspace_scale = v48 >> 16; v10 = z; goto LABEL_19; } @@ -397,11 +397,11 @@ LODWORD(v6) = 0; HIDWORD(v6) = SLOWORD(v5); v7 = pParticle->flt_28; - pParticle->field_58 = v6 / (signed int)uParticleID; + pParticle->_screenspace_scale = v6 / (signed int)uParticleID; v8 = v7; pParticle->uScreenSpaceX = HIDWORD(a5); pParticle->uScreenSpaceY = a6; - pParticle->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */v8) * (signed __int64)pParticle->field_58) >> 16; + pParticle->_screenspace_scale = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v9, */v8) * (signed __int64)pParticle->_screenspace_scale) >> 16; v10 = uParticleID; LABEL_19: pParticle->sZValue = v10; @@ -497,8 +497,8 @@ LODWORD(v13) = 0; HIDWORD(v13) = SLOWORD(pOutdoorCamera->int_fov_rad); v14 = v13 / SHIDWORD(v12); - v6->field_58 = v14; - v15 = v6->field_58; + v6->_screenspace_scale = v14; + v15 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v14 * (signed __int64)(signed int)(((unsigned __int64)(v10 * (signed __int64)v4) >> 16) @@ -536,8 +536,8 @@ v23 = v22 / (signed int)(((unsigned __int64)(v20 * (signed __int64)v5) >> 16) + ((unsigned __int64)(uIDf * (signed __int64)v4) >> 16)); - v6->field_58 = v23; - v24 = v6->field_58; + v6->_screenspace_scale = v23; + v24 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v23 * (signed __int64)(signed int)(((unsigned __int64)(v20 * (signed __int64)v4) >> 16) @@ -565,8 +565,8 @@ LODWORD(v29) = 0; HIDWORD(v29) = SLOWORD(pOutdoorCamera->int_fov_rad); v30 = v29 / X_4; - v6->field_58 = v30; - v31 = v6->field_58; + v6->_screenspace_scale = v30; + v31 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v30 * (signed __int64)v16) >> 16) >> 16); v32 = v6->flt_28; @@ -574,7 +574,7 @@ v34 = pViewport->uScreenCenterY - v33; v6->uScreenSpaceY = pViewport->uScreenCenterY - v33; v35 = v32; - v6->field_58 = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v34, */v35) * (signed __int64)v6->field_58) >> 16; + v6->_screenspace_scale = (unsigned __int64)(_48B561_mess_with_scaling_along_z(/*v34, */v35) * (signed __int64)v6->_screenspace_scale) >> 16; v6->sZValue = X_4; v36 = v6->uScreenSpaceX; if ( v36 >= (signed int)pViewport->uViewportX ) @@ -625,8 +625,8 @@ if (p->uType & 0x0100) { v14 = &pParticles[i]; - v15.field_10 = v14->field_58 / 4; - v15.field_14 = v14->field_58 / 4; + v15._screenspace_x_scaler_packedfloat = v14->_screenspace_scale / 4; + v15._screenspace_y_scaler_packedfloat = v14->_screenspace_scale / 4; v15.uScreenSpaceX = v14->uScreenSpaceX; v15.uScreenSpaceY = v14->uScreenSpaceY; v15.sZValue = v14->sZValue; @@ -658,8 +658,8 @@ } if (p->uType & 0x0400) { - v15.field_10 = p->field_58; - v15.field_14 = p->field_58; + v15._screenspace_x_scaler_packedfloat = p->_screenspace_scale; + v15._screenspace_y_scaler_packedfloat = p->_screenspace_scale; v15.uScreenSpaceX = p->uScreenSpaceX; v15.uScreenSpaceY = p->uScreenSpaceY; v15.sZValue = p->sZValue; @@ -670,8 +670,8 @@ } if (p->uType & 0x0800) { - v15.field_10 = p->field_58; - v15.field_14 = p->field_58; + v15._screenspace_x_scaler_packedfloat = p->_screenspace_scale; + v15._screenspace_y_scaler_packedfloat = p->_screenspace_scale; v15.uScreenSpaceX = p->uScreenSpaceX; v15.uScreenSpaceY = p->uScreenSpaceY; v15.sZValue = p->sZValue; @@ -683,7 +683,7 @@ } else { - v11 = 13 * p->field_58 >> 16; + v11 = 13 * p->_screenspace_scale >> 16; if ( v11 > 30 ) v11 = 30; v12 = p->uScreenSpaceY - v11; @@ -743,8 +743,8 @@ if ( BYTE1(v8) & 1 ) { pParticle = &pParticleEngine->pParticles[pParticleNum]; - pBillboard.field_10 = pParticle->field_58 >> 2; - pBillboard.field_14 = pParticle->field_58 >> 2; + pBillboard._screenspace_x_scaler_packedfloat = pParticle->_screenspace_scale / 4; + pBillboard._screenspace_y_scaler_packedfloat = pParticle->_screenspace_scale / 4; pBillboard.uScreenSpaceX = pParticle->uScreenSpaceX; pBillboard.uScreenSpaceY = pParticle->uScreenSpaceY; pBillboard.sZValue = pParticle->sZValue; @@ -778,8 +778,8 @@ } if ( *(v7 - 81) & 4 ) { - pBillboard.field_10 = *(_DWORD *)(v7 + 6); - pBillboard.field_14 = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_x_scaler_packedfloat = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_y_scaler_packedfloat = *(_DWORD *)(v7 + 6); pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18); pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14); pBillboard.sZValue = *(_DWORD *)(v7 - 2); @@ -787,8 +787,8 @@ } if ( *(v7 - 81) & 8 ) { - pBillboard.field_10 = *(_DWORD *)(v7 + 6); - pBillboard.field_14 = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_x_scaler_packedfloat = *(_DWORD *)(v7 + 6); + pBillboard._screenspace_y_scaler_packedfloat = *(_DWORD *)(v7 + 6); pBillboard.uScreenSpaceX = *(_DWORD *)(v7 - 18); pBillboard.uScreenSpaceY = *(_DWORD *)(v7 - 14); pBillboard.sZValue = *(_DWORD *)(v7 - 2);
--- a/ParticleEngine.h Tue Feb 12 15:28:08 2013 +0600 +++ b/ParticleEngine.h Tue Feb 12 15:28:36 2013 +0600 @@ -61,9 +61,17 @@ int uScreenSpaceY; int uScreenSpaceZ; // line end x int uScreenSpaceW; // line end y - int sZValue; + union + { + int sZValue; + struct + { + unsigned short object_pid; + short zbuffer_depth; + }; + }; int sZValue2; // line end z - int field_58; + int _screenspace_scale; float flt_5C; float flt_60; int uLightColor;
--- a/Render.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/Render.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -18,6 +18,7 @@ #include "DecorationList.h" #include "Allocator.h" #include "OSInfo.h" +#include "Actor.h" #include "Log.h" #include "mm7_data.h" @@ -197,8 +198,8 @@ soft_billboard.uScreenSpaceX = p->uScreenSpaceX; soft_billboard.uParentBillboardID = i; soft_billboard.uScreenSpaceY = p->uScreenSpaceY; - soft_billboard.field_10 = p->field_0; - soft_billboard.field_14 = p->field_4; + soft_billboard._screenspace_x_scaler_packedfloat = p->_screenspace_x_scaler_packedfloat; + soft_billboard._screenspace_y_scaler_packedfloat = p->_screenspace_y_scaler_packedfloat; soft_billboard.sZValue = p->sZValue; soft_billboard.uFlags = p->field_1E; soft_billboard.uTintColor = p->uTintColor; @@ -2930,32 +2931,29 @@ goto LABEL_75; } } -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); -// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); -// 4D864C: using guessed type char byte_4D864C; //----- (0047BACF) -------------------------------------------------------- void Render::TransformBillboardsAndSetPalettesODM() { //int v0; // edi@1 - char *v1; // esi@2 - unsigned int v2; // edx@3 - int v3; // eax@3 - int v4; // edi@3 - int v5; // eax@3 - __int16 v6; // di@3 - int v7; // eax@3 - int v8; // ebx@4 + //char *v1; // esi@2 + //unsigned int v2; // edx@3 + //int v3; // eax@3 + //int v4; // edi@3 + //int v5; // eax@3 + //__int16 v6; // di@3 + //int v7; // eax@3 + //int v8; // ebx@4 unsigned __int16 *v9; // eax@7 char v10; // zf@9 - DWORD v11; // eax@13 + //DWORD v11; // eax@13 int v12; // eax@13 int v13; // eax@14 RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1 int v15; // [sp+54h] [bp-10h]@13 //int v16; // [sp+58h] [bp-Ch]@1 - int v17; // [sp+5Ch] [bp-8h]@2 + //int v17; // [sp+5Ch] [bp-8h]@2 int v18; // [sp+60h] [bp-4h]@13 billboard.uParentBillboardID = -1; @@ -2966,54 +2964,42 @@ billboard.uViewportY = pViewport->uViewportY; billboard.uViewportZ = pViewport->uViewportZ - 1; billboard.uViewportW = pViewport->uViewportW; - //v0 = 0; pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw; - //v16 = 0; - for (int i = 0; i < uNumBillboardsToDraw; ++i) + for (int i = 0; i < ::uNumBillboardsToDraw; ++i) { auto pBillboard = pBillboardRenderList + i; - v17 = 0; - v1 = (char *)&pBillboardRenderList[i].uScreenSpaceY; - //do - //{ - billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; - v2 = *((short *)v1 - 5); - billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; - v3 = *((int *)v1 - 10); - billboard.uParentBillboardID = i; - v4 = *((int *)v1 + 1); - billboard.field_10 = v3; - v5 = *((int *)v1 - 9); - billboard.uTintColor = v4; - v6 = *((short *)v1 - 8); - billboard.field_14 = v5; - v7 = *((int *)v1 - 6); - billboard.sZValue = *((int *)v1 - 6); - billboard.uFlags = v2; - if ( v6 != -1 ) - { - v8 = *((short *)v1 + 1); - if ( pRenderer->pRenderD3D ) - { - billboard.sZValue = v7; - billboard.uFlags = v2; - pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[v6], v8, (RenderBillboard *)(v1 - 40)); - } - else - { + + billboard.uScreenSpaceX = pBillboard->uScreenSpaceX; + billboard.uScreenSpaceY = pBillboard->uScreenSpaceY; + billboard.uParentBillboardID = i; + billboard._screenspace_x_scaler_packedfloat = pBillboard->_screenspace_x_scaler_packedfloat; + billboard.uTintColor = pBillboard->uTintColor; + billboard._screenspace_y_scaler_packedfloat = pBillboard->_screenspace_y_scaler_packedfloat; + billboard.sZValue = pBillboard->sZValue; + billboard.uFlags = pBillboard->field_1E; + if (pBillboard->uHwSpriteID != -1) + { + if (pRenderer->pRenderD3D) + pRenderer->TransformBillboard(&billboard, + &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], + pBillboard->uPaletteSubindex, pBillboard); + else + { + assert(false); + + auto v1 = (char *)&pBillboard->uScreenSpaceY; if ( *(v1 - 10) & 2 ) v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); else - v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), v7, *((short *)v1 + 1)); + v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); v10 = (*(v1 - 9) & 1) == 0; billboard.pPalette = v9; if ( !v10 ) billboard.pPalette = pPaletteManager->field_261600[*((short *)v1 - 7)]; if ( !(billboard.uFlags & 0x40) && billboard.uFlags & 0x80 ) { - v11 = GetTickCount(); - v12 = stru_5C6E00->SinCos(v17 + v11); + v12 = stru_5C6E00->SinCos(i * 5 + GetTickCount()); v15 = abs(v12); v18 = (unsigned __int64)(15i64 * v15) >> 16; billboard.pPalette2 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 15 - v18, 1); @@ -3021,14 +3007,8 @@ v13 = *((short *)v1 - 8); if ( v13 >= 0 ) pSprites_LOD->pSpriteHeaders[v13]._4ACC38(&billboard, 1); - } - } - v17 += 5; - //v0 = v16 + 1; - v1 += 52; - //++v16; - //} - //while ( v16 < (signed int)uNumBillboardsToDraw ); + } + } } } @@ -3036,7 +3016,7 @@ //----- (0047AF11) -------------------------------------------------------- void Render::DrawLayingItems_Shooting_Magic_ODM() { - char *v0; // edi@2 + //char *v0; // edi@2 ObjectDesc *v1; // ebx@4 __int16 v2; // cx@5 RenderBillboard *v3; // esi@10 @@ -3077,19 +3057,20 @@ int a6; // [sp+20h] [bp-20h]@10 int a6a; // [sp+20h] [bp-20h]@23 int v40; // [sp+24h] [bp-1Ch]@25 - signed int v41; // [sp+28h] [bp-18h]@1 + //signed int v41; // [sp+28h] [bp-18h]@1 int v42; // [sp+2Ch] [bp-14h]@23 int y; // [sp+30h] [bp-10h]@10 int x; // [sp+34h] [bp-Ch]@10 int z; // [sp+38h] [bp-8h]@10 signed __int16 v46; // [sp+3Ch] [bp-4h]@12 - v41 = 0; - if ( (signed int)uNumLayingItems > 0 ) - { - v0 = (char *)&pLayingItems[0].uSectorID; - do - { + //v41 = 0; + for (int i = 0; i < uNumLayingItems; ++i) + { + auto v0 = (char *)&pLayingItems[i].uSectorID; + //v0 = (char *)&pLayingItems[0].uSectorID; + //do + //{ if ( *((short *)v0 - 13) ) { v1 = &pObjectList->pObjects[*((short *)v0 - 13)]; @@ -3102,7 +3083,7 @@ x = *((int *)v0 - 6); y = *((int *)v0 - 5); z = *((int *)v0 - 4); - v3 = &pBillboardRenderList[uNumBillboardsToDraw]; + v3 = &pBillboardRenderList[::uNumBillboardsToDraw]; v4 = pSpriteFrameTable->GetFrame(v1->uSpriteID, *((short *)v0 + 1)); v5 = v4; v28 = v4; @@ -3190,17 +3171,17 @@ - ((signed int)(((unsigned __int64)(v25 * (signed __int64)v40) >> 16) + 32768) >> 16); v32 = LOWORD(pViewport->uScreenCenterY) - (((unsigned int)((unsigned __int64)(v23 / v42 * v31) >> 16) + 32768) >> 16); - if ( (signed int)uNumBillboardsToDraw >= 500 ) + if (::uNumBillboardsToDraw >= 500) return; - ++uNumBillboardsToDraw; + ++::uNumBillboardsToDraw; ++uNumSpritesDrawnThisFrame; *(v0 - 2) |= 1u; v3->uPalette = v28->uPaletteIndex; v3->uIndoorSectorID = a5; - v3->field_0 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; + v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; v26 = (unsigned __int64)(v28->scale * (signed __int64)v24) >> 16; v3->pSpriteFrame = v28; - v3->field_4 = v26; + v3->_screenspace_y_scaler_packedfloat = v26; v3->field_1E = v46; v3->some_x = x; v3->some_y = y; @@ -3210,7 +3191,7 @@ HIWORD(v26) = HIWORD(v42); LOWORD(v26) = 0; v27 = (*(v0 - 2) & 0x20) == 0; - v3->sZValue = v26 + (8 * v41 | 2); + v3->sZValue = v26 + (8 * i | OBJECT_Item); v3->uPaletteSubindex = 0; v3->uTintColor = 0; if ( !v27 ) @@ -3226,10 +3207,11 @@ } } LABEL_34: - ++v41; - v0 += 112; - } - while ( v41 < (signed int)uNumLayingItems ); + ; + //++v41; + //v0 += 112; + //} + //while ( v41 < (signed int)uNumLayingItems ); } } // 4E94D3: using guessed type char byte_4E94D3; @@ -3454,9 +3436,9 @@ //----- (0047A95E) -------------------------------------------------------- -void Render::DrawDecorations() -{ - char *v0; // esi@2 +void Render::PrepareDecorationsRenderList_ODM() +{ + //char *v0; // esi@2 DecorationDesc *v1; // ebx@6 __int16 v2; // ax@6 double v3; // st7@7 @@ -3491,7 +3473,7 @@ Particle_ local_0; // [sp+Ch] [bp-98h]@7 int x; // [sp+74h] [bp-30h]@9 int y; // [sp+78h] [bp-2Ch]@9 - int v35; // [sp+7Ch] [bp-28h]@1 + //int v35; // [sp+7Ch] [bp-28h]@1 int v36; // [sp+80h] [bp-24h]@9 unsigned __int16 *v37; // [sp+84h] [bp-20h]@9 int v38; // [sp+88h] [bp-1Ch]@9 @@ -3502,12 +3484,15 @@ int a5; // [sp+9Ch] [bp-8h]@9 int b; // [sp+A0h] [bp-4h]@22 - v35 = 0; - if ( (signed int)uNumLevelDecorations > 0 ) - { - v0 = (char *)&pLevelDecorations[0].vPosition.y; - do - { + //v35 = 0; + //if ( (signed int)uNumLevelDecorations > 0 ) + //{ + //v0 = (char *)&pLevelDecorations[0].vPosition.y; + //do + for (int i = 0; i < uNumLevelDecorations; ++i) + { + auto v0 = (char *)&pLevelDecorations[i].vPosition.y; + if ( (!(*(v0 - 6) & 0x40) || ((LevelDecoration *)(v0 - 8))->_47A825()) && !(*(v0 - 6) & 0x20) ) { v1 = &pDecorationList->pDecorations[*((short *)v0 - 4)]; @@ -3625,14 +3610,14 @@ } if ( b + v25 >= (signed int)pViewport->uViewportX && v25 - b <= (signed int)pViewport->uViewportZ ) { - if ( (signed int)uNumBillboardsToDraw >= 500 ) + if (::uNumBillboardsToDraw >= 500) return; - v27 = &pBillboardRenderList[uNumBillboardsToDraw++]; + v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; ++uNumDecorationsDrawnThisFrame; v27->uHwSpriteID = *v37; v28 = v9->uPaletteIndex; - v27->field_0 = v26; - v27->field_4 = v26; + v27->_screenspace_x_scaler_packedfloat = v26; + v27->_screenspace_y_scaler_packedfloat = v26; v29 = v38; v27->uScreenSpaceX = v25; HIBYTE(v29) |= 2u; @@ -3643,7 +3628,7 @@ v27->some_z = v36; v27->uScreenSpaceY = v40; HIWORD(v30) = HIWORD(v39); - v31 = 8 * v35 | 5; + v31 = 8 * i | OBJECT_Decoration; LOWORD(v30) = 0; v27->uIndoorSectorID = 0; v27->sZValue = v30 + v31; @@ -3694,11 +3679,11 @@ } } LABEL_38: - ++v35; - v0 += 32; - } - while ( v35 < (signed int)uNumLevelDecorations ); - } + ; + //++v35; + //v0 += 32; + } + //while ( v35 < (signed int)uNumLevelDecorations ); } // 4E94D0: using guessed type char byte_4E94D0; // 5187EC: using guessed type int uNumDecorationsDrawnThisFrame; @@ -7026,33 +7011,27 @@ { IDirectDrawSurface *pFront; // eax@3 IDirectDrawSurface *pBack; // [sp-Ch] [bp-Ch]@3 - RECT *v6; // [sp-8h] [bp-8h]@3 - DWORD v7; // [sp-4h] [bp-4h]@3 if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) { pFront = (IDirectDrawSurface *)this->pFrontBuffer4; - v7 = DDBLTFAST_WAIT; - v6 = a4; pBack = (IDirectDrawSurface *)this->pBackBuffer4; } else { pFront = (IDirectDrawSurface *)this->pFrontBuffer2; - v7 = DDBLTFAST_WAIT; - v6 = a4; pBack = (IDirectDrawSurface *)this->pBackBuffer2; } - pFront->BltFast(0, 0, pBack, v6, v7); + pFront->BltFast(0, 0, pBack, a4, DDBLTFAST_WAIT); } //----- (004A1B22) -------------------------------------------------------- -unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(unsigned int a1) -{ - unsigned int v2; // ebx@1 - double v4; // st7@5 - unsigned int v5; // esi@5 - int v6; // ecx@5 +unsigned int Render::Billboard_ProbablyAddToListAndSortByZOrder(float z) +{ + //unsigned int v2; // ebx@1 + //double v4; // st7@5 + //unsigned int v5; // esi@5 + //int v6; // ecx@5 unsigned int v7; // edx@6 char *v8; // ecx@12 void *v9; // edi@16 @@ -7060,35 +7039,29 @@ void *v11; // edi@21 unsigned int v12; // eax@21 - v2 = pRenderer->uNumBillboardsToDraw; - if ( (signed int)pRenderer->uNumBillboardsToDraw >= 999 ) + //v2 = uNumBillboardsToDraw; + if (uNumBillboardsToDraw >= 999 ) return 0; - if ( !pRenderer->uNumBillboardsToDraw ) - { - pRenderer->uNumBillboardsToDraw = 1; + if (!uNumBillboardsToDraw) + { + uNumBillboardsToDraw = 1; return 0; } - v4 = *(float *)&a1; - v5 = pRenderer->uNumBillboardsToDraw; - v6 = 0; - if ( (signed int)pRenderer->uNumBillboardsToDraw <= 0 ) - { - v7 = a1; - } - else - { - do - { - v7 = v6 + (signed int)(v5 - v6) / 2; - if ( v4 <= pRenderer->pBillboardRenderListD3D[v6 + (signed int)(v5 - v6) / 2].flt_88 ) - v5 = v6 + (signed int)(v5 - v6) / 2; - else - v6 = v7 + 1; - } - while ( v6 < (signed int)v5 ); - } - v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].flt_88; - if ( v4 > *(float *)v8 ) + + //v4 = *(float *)&a1; + //v5 = pRenderer->uNumBillboardsToDraw; + //v6 = 0; + for (int left = 0, right = uNumBillboardsToDraw; left < right; ) // binsearch + { + v7 = left + (right - left) / 2; + if (z <= pRenderer->pBillboardRenderListD3D[v7].z_order) + right = v7; + else + left = v7 + 1; + } + + v8 = (char *)&pRenderer->pBillboardRenderListD3D[v7].z_order; + if (z > *(float *)v8 ) { if ( v7 == pRenderer->uNumBillboardsToDraw - 1 ) { @@ -7111,10 +7084,10 @@ ++v7; } LABEL_23: - pRenderer->uNumBillboardsToDraw = v2 + 1; + uNumBillboardsToDraw++; return v7; } - if ( v4 <= *(float *)v8 ) + if (z <= *(float *)v8 ) { if ( (signed int)pRenderer->uNumBillboardsToDraw > (signed int)v7 ) { @@ -7199,7 +7172,7 @@ if (pRenderD3D) { pGame->draw_debug_outlines(); - //DoRenderBillboards_D3D(); //Ritor1: it's temporarily + DoRenderBillboards_D3D(); //Ritor1: it's temporarily pGame->pStru6Instance->RenderSpecialEffects(); pRenderD3D->pDevice->EndScene(); } @@ -7997,7 +7970,7 @@ if ( this->uNumD3DSceneBegins ) { v4 = pSoftBillboard; - v5 = (double)HIWORD(pSoftBillboard->sZValue); + v5 = (double)pSoftBillboard->zbuffer_depth; pSoftBillboarda = v5; v6 = v5; v7 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v6)); @@ -8014,8 +7987,8 @@ pBillboardRenderListD3D[v9].uParentBillboardID = v4->uParentBillboardID; v25 = v4->uScreenSpaceX; v24 = v4->uScreenSpaceY; - a1 = (double)(v4->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_10); - v29 = (double)(v4->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v4->field_14); + a1 = (v4->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(v4->_screenspace_x_scaler_packedfloat); + v29 = (v4->_screenspace_y_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(v4->_screenspace_y_scaler_packedfloat); v31 = (double)((v10->uBufferWidth >> 1) - v10->uAreaX); v27 = (double)(v10->uBufferHeight - v10->uAreaY); if ( v4->uFlags & 4 ) @@ -8082,7 +8055,7 @@ pBillboardRenderListD3D[v9].pQuards[3].texcoord.y = 0.0; v23 = v10->pTexture; pBillboardRenderListD3D[v9].uNumVertices = 4; - pBillboardRenderListD3D[v9].flt_88 = pSoftBillboarda; + pBillboardRenderListD3D[v9].z_order = pSoftBillboarda; pBillboardRenderListD3D[v9].pTexture = v23; } } @@ -8137,9 +8110,9 @@ if ( this->uNumD3DSceneBegins ) { - if ( HIWORD(a2->sZValue) ) - { - v5 = (double)HIWORD(a2->sZValue); + if (a2->zbuffer_depth) + { + v5 = (double)a2->zbuffer_depth; v6 = v5; v7 = v5; v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); @@ -8149,7 +8122,7 @@ pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; v9 = a2->uScreenSpaceX; v10 = a2->uScreenSpaceY; - v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10); + v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); v12 = (double)v9; v13 = v12; v14 = (double)(v10 - 12); @@ -8255,7 +8228,7 @@ pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; pBillboardRenderListD3D[v8].pTexture = a3; - pBillboardRenderListD3D[v8].flt_88 = v6; + pBillboardRenderListD3D[v8].z_order = v6; pBillboardRenderListD3D[v8].uNumVertices = 4; pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; @@ -8313,7 +8286,7 @@ if ( this->uNumD3DSceneBegins ) { - v5 = (double)HIWORD(a2->sZValue); + v5 = (double)a2->zbuffer_depth; v6 = v5; v7 = v5; v8 = Billboard_ProbablyAddToListAndSortByZOrder(LODWORD(v7)); @@ -8323,7 +8296,7 @@ pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; v9 = a2->uScreenSpaceX; v10 = a2->uScreenSpaceY; - v11 = (double)(a2->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(a2->field_10); + v11 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) * 0.000015260186 + HIWORD(a2->_screenspace_x_scaler_packedfloat); v12 = (double)v9; v13 = v12; v14 = (double)(v10 - 12); @@ -8429,7 +8402,7 @@ pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; pBillboardRenderListD3D[v8].pTexture = a3; - pBillboardRenderListD3D[v8].flt_88 = v6; + pBillboardRenderListD3D[v8].z_order = v6; pBillboardRenderListD3D[v8].uNumVertices = 4; pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; @@ -8439,137 +8412,108 @@ //----- (004A4023) -------------------------------------------------------- -void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int a1a, RenderBillboard *pBillboard) -{ - RenderBillboardTransform_local0 *v5; // ebx@2 - double v6; // st7@2 - float v7; // ST08_4@2 +void Render::TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int paletteSubindex, RenderBillboard *pBillboard) +{ unsigned int v8; // esi@2 - Sprite *v9; // edi@5 - signed int v10; // eax@9 - signed int v11; // eax@9 - int v12; // eax@12 - double v13; // st7@12 double v14; // st6@14 double v15; // st5@14 - unsigned int v16; // ecx@16 - double v17; // st7@16 - double v18; // st5@16 - double v19; // st4@16 - double v20; // st5@18 - double v21; // st4@18 - IDirect3DTexture2 *v22; // eax@20 - signed int v23; // [sp+18h] [bp-18h]@5 - signed int v24; // [sp+1Ch] [bp-14h]@5 - float v25; // [sp+1Ch] [bp-14h]@12 - float v26; // [sp+20h] [bp-10h]@5 - float v27; // [sp+20h] [bp-10h]@12 - Render *a3; // [sp+24h] [bp-Ch]@1 + //unsigned int v16; // ecx@16 + //double v17; // st7@16 + //double v18; // st5@16 + //double v19; // st4@16 + //double v20; // st5@18 + //double v21; // st4@18 + //signed int v23; // [sp+18h] [bp-18h]@5 + //signed int v24; // [sp+1Ch] [bp-14h]@5 + //float v26; // [sp+20h] [bp-10h]@5 + //float v27; // [sp+20h] [bp-10h]@12 float v29; // [sp+28h] [bp-8h]@5 float v30; // [sp+2Ch] [bp-4h]@5 - float v31; // [sp+38h] [bp+8h]@2 - float pSpritea; // [sp+3Ch] [bp+Ch]@5 - float a1b; // [sp+40h] [bp+10h]@12 - float pBillboarda; // [sp+44h] [bp+14h]@12 - - auto a1 = this; - a3 = a1; - if ( a1->uNumD3DSceneBegins ) - { - v5 = a2; - v6 = (double)a2->sZValue; - v31 = v6; - v7 = v6; - v8 = Billboard_ProbablyAddToListAndSortByZOrder(v7); - if ( BYTE3(v5->uTintColor) ) - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; - else - pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; - v9 = pSprite; - pBillboardRenderListD3D[v8].field_90 = v5->field_44; - pBillboardRenderListD3D[v8].sZValue = v5->sZValue; - pBillboardRenderListD3D[v8].uParentBillboardID = v5->uParentBillboardID; - v24 = v5->uScreenSpaceX; - v23 = v5->uScreenSpaceY; - v30 = (double)(v5->field_10 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_10); - v29 = (double)(v5->field_14 & 0xFFFF) * 0.000015260186 + (double)HIWORD(v5->field_14); - pSpritea = (double)((v9->uBufferWidth >> 1) - v9->uAreaX); - v26 = (double)(v9->uBufferHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) - pSpritea = pSpritea * -1.0; - if ( v5->uTintColor & 0xFFFFFF && a3->bTinting ) - { - v10 = GetActorTintColor(a1a, 0, v31, 0, pBillboard); - v11 = sub_4A19D8(v5->uTintColor, v10); - if ( BYTE3(v5->uTintColor) ) - v11 = (unsigned int)((char *)&array_77EC08[1852].pEdgeList1[17] + 3) & ((unsigned int)v11 >> 1); - } - else - { - v11 = GetActorTintColor(a1a, 0, v31, 0, pBillboard); - } - pBillboardRenderListD3D[v8].pQuards[0].diffuse = v11; - v12 = 0; - pBillboarda = (double)v24; - pBillboardRenderListD3D[v8].pQuards[0].pos.x = pBillboarda - pSpritea * v30; - a1b = (double)v23; - pBillboardRenderListD3D[v8].pQuards[0].pos.y = a1b - v26 * v29; - v27 = v31 * 1000.0; - v13 = 1.0; - pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (v27 / (double)pOutdoorCamera->shading_dist_mist); - v25 = 1.0 / v31; - pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; - if ( a3->bUsingSpecular ) - { - v12 = sub_47C3D7_get_fog_related_stuff(0, 0, v31); - v13 = 1.0; - } - pBillboardRenderListD3D[v8].pQuards[0].specular = v12; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; - v14 = (double)((v9->uBufferWidth >> 1) - v9->uAreaX); - v15 = (double)(v9->uBufferHeight - v9->uAreaHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) + //float pSpritea; // [sp+3Ch] [bp+Ch]@5 + + if (!uNumD3DSceneBegins) + return; + + v8 = Billboard_ProbablyAddToListAndSortByZOrder(a2->zbuffer_depth); + + v30 = (a2->_screenspace_x_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_x_scaler_packedfloat); + v29 = (a2->_screenspace_y_scaler_packedfloat & 0xFFFF) / 65530.0 + HIWORD(a2->_screenspace_y_scaler_packedfloat); + + unsigned int diffuse = GetActorTintColor(paletteSubindex, 0, a2->zbuffer_depth, 0, pBillboard); + if (a2->uTintColor & 0x00FFFFFF && bTinting) + { + diffuse = sub_4A19D8(a2->uTintColor, diffuse); + if (a2->uTintColor & 0xFF000000) + diffuse = 0x007F7F7F & ((unsigned int)diffuse >> 1); + } + + unsigned int specular = 0; + if (bUsingSpecular) + specular = sub_47C3D7_get_fog_related_stuff(0, 0, a2->zbuffer_depth); + + v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); + if (a2->uFlags & 4) + v14 *= -1.0; + pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; + pBillboardRenderListD3D[v8].pQuards[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; + pBillboardRenderListD3D[v8].pQuards[0].specular = specular; + pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; + + v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); + if ( a2->uFlags & 4 ) v14 = v14 * -1.0; - v16 = pBillboardRenderListD3D[v8].pQuards[0].diffuse; - pBillboardRenderListD3D[v8].pQuards[1].specular = v12; - pBillboardRenderListD3D[v8].pQuards[1].diffuse = v16; - pBillboardRenderListD3D[v8].pQuards[1].pos.x = pBillboarda - v14 * v30; - pBillboardRenderListD3D[v8].pQuards[1].pos.y = a1b - v15 * v29; - v17 = v13 - v13 / (v27 / (double)pOutdoorCamera->shading_dist_mist); - pBillboardRenderListD3D[v8].pQuards[1].pos.z = v17; - pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; + pBillboardRenderListD3D[v8].pQuards[1].specular = specular; + pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; + pBillboardRenderListD3D[v8].pQuards[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; - v18 = (double)(v9->uAreaWidth + v9->uAreaX + (v9->uBufferWidth >> 1) - v9->uBufferWidth); - v19 = (double)(v9->uBufferHeight - v9->uAreaHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) - v18 = v18 * -1.0; - pBillboardRenderListD3D[v8].pQuards[2].diffuse = v16; - pBillboardRenderListD3D[v8].pQuards[2].specular = v12; - pBillboardRenderListD3D[v8].pQuards[2].pos.x = v18 * v30 + pBillboarda; - pBillboardRenderListD3D[v8].pQuards[2].pos.y = a1b - v19 * v29; - pBillboardRenderListD3D[v8].pQuards[2].pos.z = v17; - pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; + + v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); + if ( a2->uFlags & 4 ) + v14 *= -1.0; + pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[2].specular = specular; + pBillboardRenderListD3D[v8].pQuards[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; + pBillboardRenderListD3D[v8].pQuards[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; - v20 = (double)(v9->uAreaWidth + v9->uAreaX + (v9->uBufferWidth >> 1) - v9->uBufferWidth); - v21 = (double)(v9->uBufferHeight - v9->uAreaY); - if ( v5->uFlags & 4 ) - v20 = v20 * -1.0; - pBillboardRenderListD3D[v8].pQuards[3].diffuse = v16; - pBillboardRenderListD3D[v8].pQuards[3].specular = v12; - pBillboardRenderListD3D[v8].pQuards[3].pos.x = v20 * v30 + pBillboarda; - pBillboardRenderListD3D[v8].pQuards[3].pos.y = a1b - v21 * v29; - pBillboardRenderListD3D[v8].pQuards[3].pos.z = v17; - pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; + + v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); + v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); + if ( a2->uFlags & 4 ) + v14 *= -1.0; + pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuards[3].specular = specular; + pBillboardRenderListD3D[v8].pQuards[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; + pBillboardRenderListD3D[v8].pQuards[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuards[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; - v22 = v9->pTexture; - pBillboardRenderListD3D[v8].uNumVertices = 4; - pBillboardRenderListD3D[v8].pTexture = v22; - pBillboardRenderListD3D[v8].flt_88 = v31; - } + + pBillboardRenderListD3D[v8].uNumVertices = 4; + pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; + pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; + pBillboardRenderListD3D[v8].field_90 = a2->field_44; + pBillboardRenderListD3D[v8].sZValue = a2->sZValue; + pBillboardRenderListD3D[v8].uParentBillboardID = a2->uParentBillboardID; + + if (a2->uTintColor & 0xFF000000) + pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Opaque_3; + else + pBillboardRenderListD3D[v8].uOpacity = RenderBillboardD3D::Transparent; } @@ -8840,7 +8784,7 @@ v13 = a1->field_10; pBillboardRenderListD3D[v5].pTexture = 0; pBillboardRenderListD3D[v5].uNumVertices = v13; - LODWORD(pBillboardRenderListD3D[v5].flt_88) = v14; + LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; } } @@ -8964,8 +8908,8 @@ Render *v3; // ebx@1 HWLTexture *result; // eax@1 HWLTexture *v5; // esi@1 - unsigned int v6; // ST18_4@2 - RenderD3D *v7; // ecx@2 + //unsigned int v6; // ST18_4@2 + //RenderD3D *v7; // ecx@2 Sprite *v8; // ebx@4 unsigned __int16 *v9; // edx@5 LPVOID v10; // eax@5 @@ -8988,9 +8932,9 @@ v2->uBufferHeight = result->field_1C; v2->uAreaWidth = result->field_20; v2->uAreaHeight = result->field_24; - v6 = v3->uMinDeviceTextureDim; - v7 = v3->pRenderD3D; - if ( !v7->CreateTexture(result->uWidth, result->uHeight, &v2->pTextureSurface, &v2->pTexture, 1u, 0, v6) ) + //v6 = v3->uMinDeviceTextureDim; + //v7 = v3->pRenderD3D; + if (!pRenderD3D->CreateTexture(result->uWidth, result->uHeight, &v2->pTextureSurface, &v2->pTexture, 1u, 0, uMinDeviceTextureDim)) Abortf("HiScreen16::LoadTexture - D3Drend->CreateTexture() failed: %x", 0); //pSprite = v2->pTextureSurface; //pSprite = (Sprite *)pSprite->pName; @@ -11335,18 +11279,51 @@ 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)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); + + /*if (pRenderer->uNumBillboardsToDraw) + { + auto p = &pRenderer->pBillboardRenderListD3D[0]; + for (int i = 0; i < p->uNumVertices; ++i) + { + p->pQuards[i].pos.z -= p->pQuards[i].pos.z * 0.6; + //p->pQuards[i].rhw = + 0.8 * (1.0f - p->pQuards[i].rhw); + } + p->pQuards[0].pos.x = 10; + p->pQuards[0].pos.y = 10; + + p->pQuards[1].pos.x = 10; + p->pQuards[1].pos.y = 200; + + p->pQuards[2].pos.x = 100; + p->pQuards[2].pos.y = 200; + + p->pQuards[3].pos.x = 100; + p->pQuards[3].pos.y = 10; + + if (p->uOpacity != RenderBillboardD3D::NoBlend) + SetBillboardBlendOptions(p->uOpacity); + + pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); + ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + p->pQuards, p->uNumVertices, + D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); + + }*/ for (uint i = pRenderer->uNumBillboardsToDraw - 1; i != (uint)-1; --i) { auto p = &pRenderer->pBillboardRenderListD3D[i]; - if (p->uOpacity != RenderBillboardD3D::InvalidOpacity) + if (p->uOpacity != RenderBillboardD3D::NoBlend) SetBillboardBlendOptions(p->uOpacity); pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - p->pQuards, p->uNumVertices, D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); + ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + p->pQuards, p->uNumVertices, + D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); } if (pRenderer->bFogEnabled) @@ -11410,6 +11387,7 @@ default: Log::Warning(L"SetBillboardBlendOptions: invalid opacity type (%u)", a1); + assert(false); break; } }
--- a/Render.h Tue Feb 12 15:28:08 2013 +0600 +++ b/Render.h Tue Feb 12 15:28:36 2013 +0600 @@ -52,8 +52,8 @@ #pragma pack(push, 1) struct RenderBillboard { - int field_0; - int field_4; + int _screenspace_x_scaler_packedfloat; + int _screenspace_y_scaler_packedfloat; float fov_x; float fov_y; int sZValue; @@ -177,13 +177,13 @@ Opaque_1 = 1, Opaque_2 = 2, Opaque_3 = 3, - InvalidOpacity = 0xFFFFFFFF + NoBlend = 0xFFFFFFFF }; IDirect3DTexture2 *pTexture; unsigned int uNumVertices; RenderVertexD3D3 pQuards[4]; - float flt_88; + float z_order; OpacityType uOpacity; int field_90; int sZValue; @@ -301,7 +301,7 @@ 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(unsigned int a1); + unsigned int Billboard_ProbablyAddToListAndSortByZOrder(float z); unsigned int GetBillboardDrawListSize(); unsigned int GetParentBillboardID(unsigned int uBillboardID); void BeginSceneD3D(); @@ -316,7 +316,7 @@ void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8); 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 a1a, RenderBillboard *pBillboard); + void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int paletteSubindex, RenderBillboard *pBillboard); void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *a3, int uPaletteSubindex); 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); @@ -349,7 +349,7 @@ int OnOutdoorRedrawSW(); void DrawSkyD3D(); int DrawSkySW(struct Span *a1, stru148 *a2, int a3); - void DrawDecorations(); + void PrepareDecorationsRenderList_ODM(); void DrawLayingItems_Shooting_Magic_ODM(); void TransformBillboardsAndSetPalettesODM(); float DrawBezierTerrain(); @@ -462,13 +462,21 @@ int *pTargetZ; int uScreenSpaceX; int uScreenSpaceY; - int field_10; - int field_14; + int _screenspace_x_scaler_packedfloat; + int _screenspace_y_scaler_packedfloat; char field_18[8]; unsigned __int16 *pPalette; unsigned __int16 *pPalette2; - int sZValue; - unsigned int uFlags; + union + { + int sZValue; + struct + { + unsigned short object_pid; + short zbuffer_depth; + }; + }; + unsigned int uFlags; // & 4 - mirror horizontally unsigned int uTargetPitch; unsigned int uViewportX; unsigned int uViewportY;
--- a/mm7_1.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/mm7_1.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -2985,8 +2985,8 @@ v106.uViewportW = v12 + 128; v106.uViewportZ = v106.uViewportX + 128; v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2; - v106.field_10 = 65536; - v106.field_14 = 65536; + v106._screenspace_x_scaler_packedfloat = 65536; + v106._screenspace_y_scaler_packedfloat = 65536; v106.uScreenSpaceY = v115 + v12 + *(short *)(v11 + 18); v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1); v106.sZValue = 0;
--- a/mm7_3.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/mm7_3.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -12923,7 +12923,7 @@ v37 = v21 / x; LODWORD(v31) = v12->scale; v37 = v21 / x; - v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v21 / x) >> 16; + v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(SLODWORD(v31) * v21 / x) >> 16; v37 = (unsigned __int64)(v12->scale * (signed __int64)v37) >> 16; } else @@ -12940,7 +12940,7 @@ v37 = v20 / x; LODWORD(v31) = v12->scale; v37 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16; - v15->field_0 = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16; + v15->_screenspace_x_scaler_packedfloat = (unsigned __int64)(SLODWORD(v31) * v20 / x) >> 16; v31 = v15->fov_y; v25 = v31 + 6.7553994e15; LODWORD(v20) = 0; @@ -12949,7 +12949,7 @@ v37 = (unsigned __int64)(v12->scale * v20 / x) >> 16; } HIWORD(v22) = HIWORD(x); - v15->field_4 = v37; + v15->_screenspace_y_scaler_packedfloat = v37; v15->field_1E = v30; v15->some_x = a1; v15->some_y = a2; @@ -13108,7 +13108,7 @@ LODWORD(v19) = pBLVRenderParams->field_40 << 16; HIDWORD(v19) = pBLVRenderParams->field_40 >> 16; v20 = v19 / x; - v3->field_0 = (unsigned __int64)(v24->scale * v19 / x) >> 16; + v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * v19 / x) >> 16; v31 = (unsigned __int64)(v24->scale * (signed __int64)v20) >> 16; } else @@ -13116,11 +13116,11 @@ v3->fov_x = pGame->pIndoorCameraD3D->fov_x; v3->fov_y = pGame->pIndoorCameraD3D->fov_y; v18 = (int)floorf(v3->fov_x + 0.5f) / x; - v3->field_0 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16; + v3->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v24->scale * (__int64)v18) >> 16; v31 = (unsigned __int64)(v24->scale * (__int64)v18) >> 16; } HIWORD(v21) = HIWORD(x); - v3->field_4 = v31; + v3->_screenspace_y_scaler_packedfloat = v31; v3->field_1E = v34; v3->some_x = a1; v3->some_y = a2; @@ -13531,8 +13531,8 @@ v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16; v10.uScreenSpaceX = *((short *)v3 - 2); v10.uScreenSpaceY = *((short *)v3 - 1); - v10.field_10 = v13; - v10.field_14 = v13; + v10._screenspace_x_scaler_packedfloat = v13; + v10._screenspace_y_scaler_packedfloat = v13; v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1); v8 = *((short *)v3 - 5); v10.sZValue = 0; @@ -13860,7 +13860,7 @@ v36 = 255; flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu); v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0); - if ( bWizardEyeActive ) + if ( bWizardEyeActive = true) { uZe = 0; //for (uint i = 0; i < uNumLayingItems; ++i)
--- a/mm7_4.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/mm7_4.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -14691,7 +14691,7 @@ LODWORD(v20) = pBLVRenderParams->field_40 << 16; HIDWORD(v20) = pBLVRenderParams->field_40 >> 16; v21 = v20 / x; - v0->field_0 = (unsigned __int64)(v10->scale * v20 / x) >> 16; + v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v20 / x) >> 16; a5a = (unsigned __int64)(v10->scale * (signed __int64)v21) >> 16; } else @@ -14705,15 +14705,15 @@ LODWORD(v18) = 0; HIDWORD(v18) = floorf(v16 + 0.5f); v19 = v18 / x; - v0->field_0 = (unsigned __int64)(v10->scale * v18 / x) >> 16; + v0->_screenspace_x_scaler_packedfloat = (unsigned __int64)(v10->scale * v18 / x) >> 16; a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; } - v0->field_4 = a5a; + v0->_screenspace_y_scaler_packedfloat = a5a; 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; + a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; goto LABEL_43; } } @@ -14722,12 +14722,12 @@ v22 = p->pActorBuffs[3].uPower; if ( v22 ) { - v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16; + v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->_screenspace_x_scaler_packedfloat) >> 16; v24 = p->pActorBuffs[3].uPower; - v0->field_0 = v23; - a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16; + v0->_screenspace_x_scaler_packedfloat = v23; + a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->_screenspace_y_scaler_packedfloat) >> 16; LABEL_43: - v0->field_4 = a5b; + v0->_screenspace_y_scaler_packedfloat = a5b; goto LABEL_44; } }
--- a/stru6.cpp Tue Feb 12 15:28:08 2013 +0600 +++ b/stru6.cpp Tue Feb 12 15:28:36 2013 +0600 @@ -1585,11 +1585,11 @@ v24 = 16777216; LODWORD(v18) = 0; HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportZ) - LOWORD(pViewport->uViewportX)); - vsr.field_10 = v18 / 16777216; + vsr._screenspace_x_scaler_packedfloat = v18 / 0x1000000; LODWORD(v18) = 0; HIDWORD(v18) = (signed __int16)(LOWORD(pViewport->uViewportW) - LOWORD(pViewport->uViewportY)); v26 = v18 / 16777216; - vsr.field_14 = v18 / 16777216; + vsr._screenspace_y_scaler_packedfloat = v18 / 0x1000000; vsr.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v70->uPaletteIndex, 0, 1); vsr.uTargetPitch = pRenderer->uTargetSurfacePitch; vsr.uParentBillboardID = -1;