Mercurial > mm7
changeset 2207:ff8920a40c21
fixpoint_mul
author | Ritor1 |
---|---|
date | Thu, 06 Feb 2014 17:20:12 +0600 |
parents | 15a327be07e2 |
children | 0b2eea6f80c9 |
files | IndoorCameraD3D.cpp LOD.cpp Outdoor.cpp ParticleEngine.cpp Render.cpp SpriteObject.cpp Sprites.cpp Viewport.cpp mm7_2.cpp mm7_3.cpp mm7_5.cpp stru6.cpp |
diffstat | 12 files changed, 317 insertions(+), 382 deletions(-) [+] |
line wrap: on
line diff
--- a/IndoorCameraD3D.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/IndoorCameraD3D.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -166,12 +166,11 @@ - (unsigned __int64)(to_y * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y); //} a3a = (z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; - a2b = (unsigned __int64)(to_z * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16; + //a2b = fixpoin_mul(to_z, pGame->pIndoorCameraD3D->int_sine_x); //v10 = pOutX; - *pOutX = ((unsigned __int64)(v14 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16) - a2b; + *pOutX = fixpoint_mul(v14, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(to_z, pGame->pIndoorCameraD3D->int_sine_x); *pOutZ = v9; - *pOutY = ((unsigned __int64)(v14 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16) - + ((unsigned __int64)(a3a * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16); + *pOutY = fixpoint_mul(v14, pGame->pIndoorCameraD3D->int_sine_x) + fixpoint_mul(a3a, pGame->pIndoorCameraD3D->int_cosine_x); } else {
--- a/LOD.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/LOD.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -512,7 +512,7 @@ int v75; // [sp+48h] [bp-14h]@4 int v76; // [sp+48h] [bp-14h]@22 int v77; // [sp+48h] [bp-14h]@59 - LODSprite *v78; // [sp+4Ch] [bp-10h]@1 + //LODSprite *v78; // [sp+4Ch] [bp-10h]@1 int v79; // [sp+50h] [bp-Ch]@4 int v80; // [sp+50h] [bp-Ch]@21 int v81; // [sp+50h] [bp-Ch]@62 @@ -526,7 +526,7 @@ int v89; // [sp+68h] [bp+Ch]@56 v3 = a2; - v78 = this; + //v78 = this; result = a2->_screenspace_x_scaler_packedfloat; v58 = a2->_screenspace_x_scaler_packedfloat; if ( result <= 0 ) @@ -547,14 +547,14 @@ auto pTarget = (unsigned __int16 *)v3->pTarget; v57 = v3->sZValue; v61 = v3->pPalette; - v9 = (v6 * this->uWidth + 32768) >> 16; + v9 = (v6 * this->uWidth + 0x8000) >> 16; v72 = v3->uScreenSpaceY; - result = (v5 * v7 + 32768) >> 16; + result = (v5 * v7 + 0x8000) >> 16; v10 = (int *)(v72 - result + 1); v11 = v3->uScreenSpaceX - (v9 >> 1) + 1; v65 = v72 - result + 1; v59 = v11 + v9 - 1; - if ( BYTE1(v3->uFlags) & 8 ) + if ( v3->uFlags & 0x800 ) { v10 = (int *)((char *)v10 + (v49 >> 1)); v72 += v49 >> 1; @@ -607,7 +607,7 @@ while ( 1 ) { v35 = v71 >> 16; - v36 = LOWORD(v78->pSpriteLines[v35].dword_0); + v36 = LOWORD(this->pSpriteLines[v35].dword_0); if ( v36 == -1 ) { v34 -= v69; @@ -615,11 +615,11 @@ goto LABEL_84; } v37 = v9 - ((unsigned __int64)(v36 * (signed __int64)v58) >> 16); - v67 = v87 * ((unsigned __int64)(LOWORD(v78->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16); + v67 = v87 * ((unsigned __int64)(LOWORD(this->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16); v38 = v9 - v60; v77 = v9 - v60; if ( v9 - v60 <= (signed int)(v9 - - ((unsigned __int64)(HIWORD(v78->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16)) + - ((unsigned __int64)(HIWORD(this->pSpriteLines[v35].dword_0) * (signed __int64)v58) >> 16)) || v68 >= v37 ) { v89 -= v69; @@ -640,15 +640,15 @@ v89 += v39 + v60; v86 += v60 + v39; } - v40 = ((HIWORD(v78->pSpriteLines[v35].dword_0) + 1) << 16) - v81 - v67; + v40 = ((HIWORD(this->pSpriteLines[v35].dword_0) + 1) << 16) - v81 - v67; LODWORD(v41) = v40 << 16; HIDWORD(v41) = v40 >> 16; - v42 = v77 - (((signed int)((unsigned __int64)(v41 / v48) - 32768) >> 16) + 1); + v42 = v77 - (((signed int)((unsigned __int64)(v41 / v48) - 0x8000) >> 16) + 1); if ( v68 >= v42 ) v42 = v68; v43 = &pTarget[v89]; v74 = &v43[v42 - v77 + 1]; - v44 = &v78->pSpriteLines[v35]; + v44 = &this->pSpriteLines[v35]; v64 = v44->ptr_4; if ( !v57 ) { @@ -661,7 +661,7 @@ } while ( v43 >= v74 ) { - v46 = (v83 - ((signed int)LOWORD(v78->pSpriteLines[v35].dword_0) << 16)) >> 16; + v46 = (v83 - ((signed int)LOWORD(this->pSpriteLines[v35].dword_0) << 16)) >> 16; if ( *((char *)v64 + v46) ) *v43 = v61[*((char *)v64 + v46)]; v83 += v87; @@ -687,7 +687,7 @@ if ( !v51 ) return result; } - v45 = (v82 - ((signed int)LOWORD(v78->pSpriteLines[v35].dword_0) << 16)) >> 16; + v45 = (v82 - ((signed int)LOWORD(this->pSpriteLines[v35].dword_0) << 16)) >> 16; v56 = *((char *)v64 + v45); if ( *((char *)v64 + v45) && v57 <= (unsigned int)*pTargetZ ) { @@ -709,7 +709,7 @@ v50 = result - (int)v16 + 1; while ( 1 ) { - v20 = &v78->pSpriteLines[v71 >> 16]; + v20 = &this->pSpriteLines[v71 >> 16]; v80 = v71 >> 16; if ( LOWORD(v20->dword_0) != -1 ) break; @@ -754,7 +754,7 @@ v22 = v26; v27 = &pTarget[v88]; v73 = &v27[v22 - v76 - 1]; - v28 = &v78->pSpriteLines[v80]; + v28 = &this->pSpriteLines[v80]; v63 = v28->ptr_4; if ( v57 ) { @@ -778,7 +778,7 @@ } } v30 = v29 >> 16; - if ( v30 > HIWORD(v78->pSpriteLines[v80].dword_0) - (signed int)LOWORD(v78->pSpriteLines[v80].dword_0) + if ( v30 > HIWORD(this->pSpriteLines[v80].dword_0) - (signed int)LOWORD(this->pSpriteLines[v80].dword_0) || (v31 = *((char *)v63 + v30)) == 0 || v57 > (unsigned int)*pTargetZ ) goto LABEL_50; @@ -801,7 +801,7 @@ ++v27; } v33 = v32 >> 16; - if ( v33 > HIWORD(v78->pSpriteLines[v80].dword_0) - (signed int)LOWORD(v78->pSpriteLines[v80].dword_0) + if ( v33 > HIWORD(this->pSpriteLines[v80].dword_0) - (signed int)LOWORD(this->pSpriteLines[v80].dword_0) || (v31 = *((char *)v63 + v33)) == 0 ) goto LABEL_50; }
--- a/Outdoor.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/Outdoor.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -33,6 +33,7 @@ #include "BSPModel.h" #include "GUIWindow.h" #include "Level/Decoration.h" +#include "OurMath.h" MapStartPoint uLevel_StartingPointType; // weak @@ -2971,8 +2972,8 @@ v24 = pBModel->pVertices.pVertices[pFace->pVertexIDs[0]].z; else { - int a = ((signed __int64)(pFace->zCalc1 * (signed __int64)X) >> 16); - int b = ((signed __int64)(pFace->zCalc2 * (signed __int64)Y) >> 16); + int a = fixpoint_mul(pFace->zCalc1, X); + int b = fixpoint_mul(pFace->zCalc2, Y); int c = ((signed __int64)pFace->zCalc3 >> 16); v24 = a + b + c; } @@ -4451,8 +4452,7 @@ if ( pOutdoor->pBModels[i].pFaces[j].uPolygonType == POLYGON_Ceiling ) v19 = pOutdoor->pBModels[i].pVertices.pVertices[pOutdoor->pBModels[i].pFaces[j].pVertexIDs[0]].z; else - v19 = ((unsigned __int64)(pOutdoor->pBModels[i].pFaces[j].zCalc1 * (signed __int64)Party_X) >> 16) - + ((unsigned __int64)(pOutdoor->pBModels[i].pFaces[j].zCalc2 * (signed __int64)Party_Y) >> 16) + v19 = fixpoint_mul(pOutdoor->pBModels[i].pFaces[j].zCalc1, Party_X) + fixpoint_mul(pOutdoor->pBModels[i].pFaces[j].zCalc2, Party_Y) + HIWORD(pOutdoor->pBModels[i].pFaces[j].zCalc3); v20 = v39++; ceiling_height_level[v20] = v19;
--- a/ParticleEngine.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/ParticleEngine.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -458,7 +458,7 @@ int v3; // ebx@1 int v4; // edi@1 int v5; // ecx@1 - Particle *v6; // esi@1 + //Particle *v6; // esi@1 //double v7; // ST14_8@2 //double v8; // ST34_8@4 //double v9; // ST3C_8@4 @@ -485,11 +485,11 @@ //int v30; // eax@13 //int v31; // ST1C_4@13 //double v32; // st7@13 - signed int v33; // eax@13 + //signed int v33; // eax@13 //int v34; // ecx@13 //float v35; // ST04_4@13 - int v36; // eax@13 - int v37; // esi@15 + //int v36; // eax@13 + //int v37; // esi@15 //double v39; // [sp+10h] [bp-40h]@2 int v40; // [sp+14h] [bp-3Ch]@12 //int v41; // [sp+1Ch] [bp-34h]@2 @@ -512,8 +512,8 @@ v4 = stru_5C6E00->Cos(pGame->pIndoorCameraD3D->sRotationY); v5 = stru_5C6E00->Sin(pGame->pIndoorCameraD3D->sRotationY); - v6 = &pParticles[uID]; - if (v6->type == ParticleType_Invalid) + //v6 = &pParticles[uID]; + if (pParticles[uID].type == ParticleType_Invalid) return false; //v7 = v6->x + 6.7553994e15; @@ -522,46 +522,49 @@ //v42 = v6->z + 6.7553994e15; if ( v3 ) { - if (v6->type & ParticleType_Line) + if (pParticles[uID].type & ParticleType_Line) { //v8 = v6->_x + 6.7553994e15; //uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16; //v9 = v6->_y + 6.7553994e15; //v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16; - v11 = fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); + v11 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); //HIDWORD(v8) = fixpoint_sub_unknown(v6->x - pIndoorCamera->pos.x, v5); //v12 = v6->_z + 6.7553994e15; //uIDd = (LODWORD(v12) - pIndoorCamera->pos.z) << 16; - long long _hidword_v12 = fixpoint_mul(v11, v3) + fixpoint_sub_unknown(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44); + long long _hidword_v12 = fixpoint_mul(v11, v3) + fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44); LODWORD(v13) = 0; HIDWORD(v13) = SLOWORD(pODMRenderParams->int_fov_rad); //v14 = v13 / _hidword_v12; - v6->_screenspace_scale = v13 / _hidword_v12; + pParticles[uID]._screenspace_scale = v13 / _hidword_v12; //v15 = v6->_screenspace_scale; - v6->uScreenSpaceX = pViewport->uScreenCenterX - - ((signed int)((unsigned __int64)(v6->_screenspace_scale - * (signed __int64)(fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - - fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16) >> 16); - v6->uScreenSpaceY = pViewport->uScreenCenterY - - ((signed int)((unsigned __int64)(v6->_screenspace_scale - * (signed __int64)(fixpoint_sub_unknown(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - - ((unsigned __int64)(v11 * (signed __int64)v44) >> 16))) >> 16) >> 16); - v6->sZValue = _hidword_v12; + pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX + - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y + - pGame->pIndoorCameraD3D->vPartyPos.y, v4) + - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16); + pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY + - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].z + - pGame->pIndoorCameraD3D->vPartyPos.z, v3) + - fixpoint_mul(v11, v44))) >> 16); + pParticles[uID].sZValue = _hidword_v12; } //uIDe = (v41 - pIndoorCamera->pos.x) << 16; //v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; - v45 = fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); + v45 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(pParticles[uID].y + - pGame->pIndoorCameraD3D->vPartyPos.y, v5); //HIDWORD(v42) = fixpoint_sub_unknown(v6->x - pIndoorCamera->pos.x, v5); //uIDa = (LODWORD(v42) - pIndoorCamera->pos.z) << 16; - X_4 = fixpoint_sub_unknown(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_mul(v45, v3); + X_4 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_mul(v45, v3); if ( X_4 < 0x40000 ) return 0; - v16 = fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); - v17 = fixpoint_sub_unknown(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_mul(v45, v44); + v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) + - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); + v17 = fixpoint_sub_unknown(pParticles[uID].z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_mul(v45, v44); } else { - if (v6->type & ParticleType_Line) + if (pParticles[uID].type & ParticleType_Line) { //v18 = v6->_x + 6.7553994e15; //uIDf = (LODWORD(v18) - pIndoorCamera->pos.x) << 16; @@ -570,26 +573,28 @@ //v21 = v6->_z + 6.7553994e15; LODWORD(v22) = 0; HIDWORD(v22) = SLOWORD(pODMRenderParams->int_fov_rad); - long long _var_123 = fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); + long long _var_123 = fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + + fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); //v23 = v22 / _var_123; - v6->_screenspace_scale = v22 / _var_123; + pParticles[uID]._screenspace_scale = v22 / _var_123; //v24 = v6->_screenspace_scale; - v6->uScreenSpaceX = pViewport->uScreenCenterX - - ((signed int)((unsigned __int64)(v6->_screenspace_scale - * (signed __int64)(fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - - fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16) >> 16); - v6->uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_sub_unknown(v6->z, v6->_screenspace_scale) >> 16); - v6->sZValue = _var_123; + pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX + - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, (fixpoint_sub_unknown(pParticles[uID].y + - pGame->pIndoorCameraD3D->vPartyPos.y, v4) + - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16); + pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_sub_unknown(pParticles[uID].z, pParticles[uID]._screenspace_scale) >> 16); + pParticles[uID].sZValue = _var_123; } //uIDb = (v41 - pIndoorCamera->pos.x) << 16; //v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; - v26 = fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); + v26 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); //v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16); - X_4 = v26 + fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4); + X_4 = v26 + fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v4); if ( X_4 < 0x40000 || X_4 > (pODMRenderParams->uPickDepth - 1000) << 16 ) return 0; - v17 = v6->z; - v16 = fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); + v17 = pParticles[uID].z; + v16 = fixpoint_sub_unknown(pParticles[uID].y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) + - fixpoint_sub_unknown(pParticles[uID].x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); } v40 = v17; v28 = abs(v16); @@ -598,24 +603,23 @@ LODWORD(v29) = 0; HIDWORD(v29) = SLOWORD(pODMRenderParams->int_fov_rad); //v30 = v29 / X_4; - v6->_screenspace_scale = v29 / X_4; + pParticles[uID]._screenspace_scale = v29 / X_4; //v31 = v6->_screenspace_scale; - v6->uScreenSpaceX = pViewport->uScreenCenterX - - ((signed int)((unsigned __int64)(v6->_screenspace_scale * (signed __int64)v16) >> 16) >> 16); - v33 = (signed int)((unsigned __int64)(v6->_screenspace_scale * (signed __int64)v40) >> 16) >> 16; + pParticles[uID].uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, v16) >> 16); + //v33 = (signed int)fixpiont_mul(v6->_screenspace_scale, v40) >> 16; //v34 = pViewport->uScreenCenterY - v33; - v6->uScreenSpaceY = pViewport->uScreenCenterY - v33; - v6->_screenspace_scale = fixpoint_mul(fixpoint_from_float(v6->flt_28), v6->_screenspace_scale); - v6->sZValue = X_4; - v36 = v6->uScreenSpaceX; - if ( v36 >= (signed int)pViewport->uViewportTL_X ) + pParticles[uID].uScreenSpaceY = pViewport->uScreenCenterY - (signed int)fixpoint_mul(pParticles[uID]._screenspace_scale, v40) >> 16; + pParticles[uID]._screenspace_scale = fixpoint_mul(fixpoint_from_float(pParticles[uID].flt_28), pParticles[uID]._screenspace_scale); + pParticles[uID].sZValue = X_4; + //v36 = v6->uScreenSpaceX; + if ( pParticles[uID].uScreenSpaceX >= (signed int)pViewport->uViewportTL_X ) { - if ( v36 < (signed int)pViewport->uViewportBR_X ) + if ( pParticles[uID].uScreenSpaceX < (signed int)pViewport->uViewportBR_X ) { - v37 = v6->uScreenSpaceY; - if ( v37 >= (signed int)pViewport->uViewportTL_Y ) + //v37 = v6->uScreenSpaceY; + if ( pParticles[uID].uScreenSpaceY >= (signed int)pViewport->uViewportTL_Y ) { - if ( v37 < (signed int)pViewport->uViewportBR_Y ) + if ( pParticles[uID].uScreenSpaceY < (signed int)pViewport->uViewportBR_Y ) return 1; } }
--- a/Render.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/Render.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -998,10 +998,7 @@ v37 = v10; v12 = v42; v38 = 0; - v13 = ((signed int)(stru_5C6E00->uIntegerPi - + ((signed int)stru_5C6E00->uIntegerPi >> 3) - + v11 - - (signed int)v37) >> 8) & 7; + v13 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v11 - (signed int)v37) >> 8) & 7; v37 = (unsigned __int16 *)v13; if ( v42 & 2 ) v38 = 2; @@ -1026,37 +1023,29 @@ v15 = 255; } b = v16; - pStationaryLightsStack->AddLight( - decor->vPosition.x, - decor->vPosition.y, - decor->vPosition.z + decor_desc->uDecorationHeight / 2, - a5, - v14, - v15, - v16, - _4E94D0_light_type); + pStationaryLightsStack->AddLight(decor->vPosition.x, decor->vPosition.y, decor->vPosition.z + decor_desc->uDecorationHeight / 2, + a5, v14, v15, v16, _4E94D0_light_type); } v17 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; if (pGame->pIndoorCameraD3D->sRotationX) { v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; - v18 = ((unsigned __int64)(v17 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16); + v18 = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y) + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); v42 = v18; - b = (unsigned __int64)(v17 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; - a5 = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; + b = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_sine_y); + a5 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y); v40 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; - v41 = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16; - v19 = (unsigned __int64)(v18 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16; - v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16); - v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16); - if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) + v41 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_x); + v19 = fixpoint_mul(v18, pGame->pIndoorCameraD3D->int_cosine_x); + v20 = v19 + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_x); + v39 = v19 + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_x); + if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) { v21 = a5 - b; v41 = a5 - b; - a5 = (unsigned __int64)(v42 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_x) >> 16; - b = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16; - v22 = ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_x) >> 16) - a5; + //a5 = fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_x); + b = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_x); + v22 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_x); LABEL_30: v42 = v22; v40 = 2 * abs(v20); @@ -1066,26 +1055,24 @@ LODWORD(v24) = 0; HIDWORD(v24) = SLOWORD(pODMRenderParams->int_fov_rad); a5 = v24 / v39; - v25 = pViewport->uScreenCenterX - - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); - b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; + v25 = pViewport->uScreenCenterX - ((signed int)(fixpoint_mul(v24 / v39, v41) + 0x8000) >> 16); + b = fixpoint_mul(a5, v42); v41 = v24 / v39; - v40 = pViewport->uScreenCenterY - - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); - v42 = v8->scale; - v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; + v40 = pViewport->uScreenCenterY - ((signed int)(fixpoint_mul(a5, v42) + 0x8000) >> 16); + //v42 = v8->scale; + v41 = fixpoint_mul(v8->scale, v24 / v39); v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; if ( pRenderer->pRenderD3D ) { v26 = v41; - v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; - b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; + //v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth / 2; + b = fixpoint_mul(pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth / 2, v41); } else { v26 = v41; - v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; - b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; + //v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth / 2; + b = fixpoint_mul(pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth / 2, v41); } if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) { @@ -1123,16 +1110,16 @@ { v42 = (decor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x) << 16; v40 = (decor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y) << 16; - b = (unsigned __int64)(v17 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; - a5 = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; - v20 = b + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16); - v39 = b + ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16); - if ( v20 >= 262144 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) + b = fixpoint_mul(v17, pGame->pIndoorCameraD3D->int_cosine_y); + a5 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); + v20 = b + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); + v39 = b + fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_sine_y); + if ( v20 >= 0x40000 && v20 <= pODMRenderParams->shading_dist_mist << 16 ) { - a5 = (unsigned __int64)(v42 * (signed __int64)pGame->pIndoorCameraD3D->int_sine_y) >> 16; - b = (unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16; - v21 = ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - a5; - v41 = ((unsigned __int64)(v40 * (signed __int64)pGame->pIndoorCameraD3D->int_cosine_y) >> 16) - a5; + a5 = fixpoint_mul(v42, pGame->pIndoorCameraD3D->int_sine_y); + b = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y); + v21 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - a5; + v41 = fixpoint_mul(v40, pGame->pIndoorCameraD3D->int_cosine_y) - a5; v22 = (decor->vPosition.z - pGame->pIndoorCameraD3D->vPartyPos.z) << 16; goto LABEL_30; } @@ -4959,13 +4946,13 @@ for ( _507D30_idx; _507D30_idx < pSkyPolygon.uNumVertices; _507D30_idx++ ) { //v15 = (void *)(v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY)); - v77 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_west_east * (signed __int64)(v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY))) >> 16; + v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); v74 = v77 + pSkyPolygon.ptr_38->angle_from_north; - v77 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_north_south * (signed __int64)(v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY))) >> 16; + v77 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v72 * (v70 - array_507D30[_507D30_idx].vWorldViewProjY)); v74_ = v77 + pSkyPolygon.ptr_38->angle_from_east; - v79 = (void *)(((unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))) >> 16); + v79 = (void *)(fixpoint_mul(pSkyPolygon.v_18.z, v72 * (v70 - (int)array_507D30[_507D30_idx].vWorldViewProjY))); v17 = v72 * (pBLVRenderParams->uViewportCenterX - (int)array_507D30[_507D30_idx].vWorldViewProjX); v18 = array_507D30[_507D30_idx].vWorldViewProjY - 1.0; v19 = -pSkyPolygon.field_24; @@ -4986,8 +4973,8 @@ v19 = v77; v20 = v79; LABEL_14: - v79 = (void *)((unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v20) >> 16); - v22 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v20) >> 16; + v79 = (void *)fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); + v22 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v20); --LODWORD(v76); v20 = (char *)v20 + v72; X = v22 + pSkyPolygon.v_18.x; @@ -4999,16 +4986,16 @@ HIDWORD(v23) = v77 >> 16;//v23 = 0xfffffe0000000000 v79 = (void *)(v23 / X);//X = FFFF9014(-28652) v77 = v17; - signed __int64 s = v74 + ((pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v17) >> 16);// s = 0xFFFFFFFF FFFF3EE6 - LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(s) * (v23 / X)) >> 16) >> 4); + signed __int64 s = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v17);// s = 0xFFFFFFFF FFFF3EE6 + LODWORD(v80) = v66 + ((signed int)fixpoint_mul(SLODWORD(s), v23 / X) >> 4); array_507D30[_507D30_idx].u = ((double)SLODWORD(v80) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); - signed __int64 s2 = (signed __int64)(v74_ + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v17) >> 16)); - LODWORD(v80) = v63 + ((signed int)((unsigned __int64)(SLODWORD(s2) * (v23 / X)) >> 16) >> 4); + signed __int64 s2 = v74_ + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v17); + LODWORD(v80) = v63 + ((signed int)fixpoint_mul(SLODWORD(s2), v23 / X) >> 4); array_507D30[_507D30_idx].v = ((double)SLODWORD(v80) * 0.000015259022) * v68; - v77 = (unsigned __int64)(SLODWORD(s) * (v23 / X)) >> 16; - LODWORD(v73) = (unsigned __int64)(SLODWORD(s2) * (v23 / X)) >> 16; + v77 = fixpoint_mul(SLODWORD(s), v23 / X); + LODWORD(v73) = fixpoint_mul(SLODWORD(s2), v23 / X); array_507D30[_507D30_idx]._rhw = 65536.0 / (double)(signed int)v79; //if ( (int)v81 >= pSkyPolygon.uNumVertices ) @@ -5073,19 +5060,18 @@ v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjY)); //v78 = pSkyPolygon.ptr_38->viewing_angle_from_west_east; - v81 = (const void *)((unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_west_east * (signed __int64)(signed int)v35) >> 16); - v36 = (int)((char *)v81 + pSkyPolygon.ptr_38->angle_from_north); + //v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v35); + v36 = (int)(fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, (int)v35) + pSkyPolygon.ptr_38->angle_from_north); v81 = v35; v74 = v36; //v78 = pSkyPolygon.ptr_38->viewing_angle_from_north_south; - v81 = (const void *)((unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_north_south * (signed __int64)(signed int)v35) >> 16); + v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, (int)v35); v78 = (int)v35; v75 = (RenderVertexSoft *)((char *)v81 + pSkyPolygon.ptr_38->angle_from_east); - v81 = (const void *)pSkyPolygon.v_18.z; - v78 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(signed int)v35) >> 16; - v37 = (const void *)(v72 - * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); + //v81 = (const void *)pSkyPolygon.v_18.z; + v78 = fixpoint_mul(pSkyPolygon.v_18.z, (int)v35); + v37 = (const void *)(v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)array_50AC10[j].vWorldViewProjX)); v38 = (signed __int64)(array_50AC10[j].vWorldViewProjY - 1.0); v81 = 0; LODWORD(v76) = v38; @@ -5103,7 +5089,7 @@ v39 = v78; LABEL_36: v78 = pSkyPolygon.v_18.z; - v41 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v39) >> 16; + v41 = fixpoint_mul(pSkyPolygon.v_18.z, v39); --LODWORD(v76); v39 += v72; X = v41 + pSkyPolygon.v_18.x; @@ -5113,11 +5099,8 @@ { v79 = (void *)pSkyPolygon.v_18.z; v78 = 2 * LODWORD(v76); - v81 = (const void *)((unsigned __int64)(pSkyPolygon.v_18.z - * (signed __int64)(signed int)(signed __int64)(((double)v70 - - ((double)(2 * LODWORD(v76)) - - array_50AC10[j].vWorldViewProjY)) - * (double)v72)) >> 16); + v81 = (const void *)fixpoint_mul(pSkyPolygon.v_18.z, (((double)v70 - ((double)(2 * LODWORD(v76)) - array_50AC10[j].vWorldViewProjY)) + * (double)v72)); X = (int)((char *)v81 + pSkyPolygon.v_18.x); } LODWORD(v42) = v77 << 16; @@ -5126,23 +5109,23 @@ v81 = v37; //v78 = pSkyPolygon.ptr_38->angle_from_west; - v81 = (const void *)((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)(signed int)v37) >> 16); - v43 = v74 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)(signed int)v37) >> 16); + v81 = (const void *)fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); + v43 = v74 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, (int)v37); v74 = (unsigned int)v37; LODWORD(v76) = v43; //v78 = pSkyPolygon.ptr_38->angle_from_south; - v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)(signed int)v37) >> 16)); - v74 = (unsigned __int64)(v43 * v42 / X) >> 16; - v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16); + v75 = (RenderVertexSoft *)((char *)v75 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, (int)v37)); + //v74 = fixpoint_mul(v43, v42 / X); + v81 = (const void *)fixpoint_mul((int)v75, v42 / X); //v34 += 48; - v78 = v66 + ((signed int)v74 >> 4); + //v78 = v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4); //v44 = HIDWORD(v69)-- == 1; - v45 = (double)v78 * 0.000015259022; - v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); - array_50AC10[j].u = v45 * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); - array_50AC10[j].v = (double)v78 * 0.000015259022 * v68; + //v45 = (double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022; + //v78 = v63 + ((signed int)fixpoint_mul((int)v75, v42 / X) >> 4); + array_50AC10[j].u = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * (1.0 / (double)pSkyPolygon.pTexture->uTextureWidth); + array_50AC10[j].v = ((double)(v66 + ((signed int)fixpoint_mul(v43, v42 / X) >> 4)) * 0.000015259022) * v68; //v46 = (double)(signed int)v79; array_50AC10[j].vWorldViewPosition.x = 0.000015258789 * (double)(signed int)v79; array_50AC10[j]._rhw = 65536.0 / (double)(signed int)v79; @@ -8749,10 +8732,10 @@ array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; - v51 = (unsigned __int64)(-pOutdoor->vSunlight.x * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x) >> 16; - v53 = (unsigned __int64)(-pOutdoor->vSunlight.y * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y) >> 16; - v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >> 16; - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - (20 * (signed int)(v51 + v53 + v52) >> 16); + v51 = fixpoint_mul(-pOutdoor->vSunlight.x, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x); + v53 = fixpoint_mul(-pOutdoor->vSunlight.y, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y); + v52 = fixpoint_mul(-pOutdoor->vSunlight.z, pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z); + array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - fixpoint_mul(20, v51 + v53 + v52); if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) @@ -8915,13 +8898,13 @@ // íàïðàâëåíèå íà ñåâåð è/èëè þã (ëèáî íà âîñòîê è/èëè çàïàä), çíà÷åíèþ 65536 åäåíèöàì(0õ10000) ñîîòâåòñòâóåò óãîë 90. // äâå ïåðåìåííûå õðàíÿò äàííûå ïî óãëó îáçîðà. field_14 ïî çàïàäó è âîñòîêó. field_20 ïî þãó è ñåâåðó // îò -25080 äî 25080 - v39 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_west_east * (signed __int64)(v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)))) >> 16; + v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_west_east, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); v35 = v39 + pSkyPolygon.ptr_38->angle_from_north; - v39 = (unsigned __int64)(pSkyPolygon.ptr_38->viewing_angle_from_north_south * (signed __int64)(v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f)))) >> 16; + v39 = fixpoint_mul(pSkyPolygon.ptr_38->viewing_angle_from_north_south, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.f))); v36 = v39 + pSkyPolygon.ptr_38->angle_from_east; - v9 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)(v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5)))) >> 16; + v9 = fixpoint_mul(pSkyPolygon.v_18.z, v33 * (v30 - floor(array_50AC10[i].vWorldViewProjY + 0.5))); v10 = pSkyPolygon.v_18.x + v9; if ( v10 > 0 ) v10 = 0; @@ -8941,7 +8924,7 @@ break; } } - v16 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v14) >> 16; + v16 = fixpoint_mul(pSkyPolygon.v_18.z, v14); --v32; v14 += v33; v10 = pSkyPolygon.v_18.x + v16; @@ -8951,14 +8934,12 @@ v18 = v17 / v10; if ( v18 < 0 ) v18 = pODMRenderParams->shading_dist_mist; - v37 = v35 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_west * (signed __int64)v13) >> 16); - v35 = 224 * pMiscTimer->uTotalGameTimeElapsed - + ((signed int)((unsigned __int64)(v37 * (signed __int64)v18) >> 16) >> 3); + v37 = v35 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_west, v13); + v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v37, v18) >> 3); array_50AC10[i].u = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureWidth * 65536.0); - v36 = v36 + ((unsigned __int64)(pSkyPolygon.ptr_38->angle_from_south * (signed __int64)v13) >> 16); - v35 = 224 * pMiscTimer->uTotalGameTimeElapsed - + ((signed int)((unsigned __int64)(v36 * (signed __int64)v18) >> 16) >> 3); + v36 = v36 + fixpoint_mul(pSkyPolygon.ptr_38->angle_from_south, v13); + v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + ((signed int)fixpoint_mul(v36, v18) >> 3); array_50AC10[i].v = (double)v35 / ((double)pSkyPolygon.pTexture->uTextureHeight * 65536.0); array_50AC10[i].vWorldViewPosition.x = (double)0x2000;//pODMRenderParams->shading_dist_mist 8192 @@ -9039,6 +9020,19 @@ for (uint x = 0; x < width; ++x) { //*v3 = pRenderer->ReadPixel16((int)(x* interval_x + 8.0), (int)(y * interval_y + 8.0));//screen_data[screen_y + (int)(x* interval_x + 8.0)]; + /* + if (ddpfPrimarySuface.dwRGBBitCount == 32) + { + auto p = (unsigned __int32 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; + *v3 = Color16((*p >> 16) & 255, (*p >> 8) & 255, *p & 255); + } + else if (ddpfPrimarySuface.dwRGBBitCount == 16) + { + auto p = (unsigned __int16 *)pRenderer->pTargetSurface + (int)(x * interval_x + 8.0) + (int)(y * interval_y + 8.0) * pRenderer->uTargetSurfacePitch; + *v3 = *p; + } + */ + pRenderer->pTargetSurface; if (Dst.ddpfPixelFormat.dwRGBBitCount == 32) { auto p = (unsigned __int32 *)Dst.lpSurface + (int)(x * interval_x + 8.0) + y/* (int)(y * interval_y + 8.0)*/ * Dst.lPitch;
--- a/SpriteObject.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/SpriteObject.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -274,9 +274,7 @@ } } else - { v58 = 1; - } if ( !(object->uFlags & OBJECT_DESC_NO_GRAVITY) ) { if ( v58 ) @@ -493,21 +491,19 @@ + face->pFacePlane.vNormal.z * pSpriteObjects[uLayingItemID].vVelocity.z) >> 16; if ( (stru_721530.speed >> 3) > v56 ) v56 = stru_721530.speed >> 3; - v57 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.x) >> 16; - v58 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.y) >> 16; - v60 = (unsigned __int64)(v56 * (signed __int64)face->pFacePlane.vNormal.z) >> 16; - pSpriteObjects[uLayingItemID].vVelocity.x += 2 * v57; - pSpriteObjects[uLayingItemID].vVelocity.y += 2 * v58; + //v57 = fixpoint_mul(v56, face->pFacePlane.vNormal.x); + //v58 = fixpoint_mul(v56, face->pFacePlane.vNormal.y); + v60 = fixpoint_mul(v56, face->pFacePlane.vNormal.z); + pSpriteObjects[uLayingItemID].vVelocity.x += 2 * fixpoint_mul(v56, face->pFacePlane.vNormal.x); + pSpriteObjects[uLayingItemID].vVelocity.y += 2 * fixpoint_mul(v56, face->pFacePlane.vNormal.y); if ( face->pFacePlane.vNormal.z <= 32000 ) - { v37 = 2 * (short)v60; - } else { v36 = v60; pSpriteObjects[uLayingItemID].vVelocity.z += (signed __int16)v60; - v58 = (unsigned __int64)(32000 * (signed __int64)(signed int)v36) >> 16; - v37 = (unsigned int)(32000 * v36) >> 16; + v58 = fixpoint_mul(0x7D00, v36); + v37 = fixpoint_mul(32000, v36); } pSpriteObjects[uLayingItemID].vVelocity.z += v37; if ( BYTE3(face->uAttributes) & 0x10 ) @@ -518,7 +514,7 @@ if ( pSpriteObjects[uLayingItemID].vVelocity.x * pSpriteObjects[uLayingItemID].vVelocity.x + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y >= 400 ) { - if ( BYTE3(face->uAttributes) & 0x10 ) + if ( face->uAttributes & 0x10000000 ) EventProcessor(face->sCogTriggeredID, 0, 1); goto LABEL_74; } @@ -536,8 +532,8 @@ + pSpriteObjects[uLayingItemID].vVelocity.y * pSpriteObjects[uLayingItemID].vVelocity.y); v38 = stru_5C6E00->Atan2(pSpriteObjects[uLayingItemID].vPosition.x - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y - pLevelDecorations[PID_ID(stru_721530.uFaceID)].vPosition.y); - pSpriteObjects[uLayingItemID].vVelocity.x = (unsigned __int64)(stru_5C6E00->Cos(v38) * (signed __int64)v57) >> 16; - pSpriteObjects[uLayingItemID].vVelocity.y = (unsigned __int64)(stru_5C6E00->Sin(v38 - stru_5C6E00->uIntegerHalfPi) * (signed __int64)v57) >> 16; + pSpriteObjects[uLayingItemID].vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v38), v57); + pSpriteObjects[uLayingItemID].vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v38 - stru_5C6E00->uIntegerHalfPi), v57); goto LABEL_74; } }
--- a/Sprites.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/Sprites.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -13,7 +13,7 @@ #include "MM7.h" #include "Actor.h" #include "Level/Decoration.h" - +#include "OurMath.h" @@ -784,8 +784,7 @@ if ( v14 > 0 ) { v15 = v5->vPosition.z; - v16 = stru_721530.normal.z - + ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v14) >> 16); + v16 = stru_721530.normal.z + fixpoint_mul(stru_721530.direction.z, v14); if ( v16 >= v15 ) { if ( v16 <= v22 + v15 )
--- a/Viewport.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/Viewport.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -127,7 +127,7 @@ //----- (00443249) -------------------------------------------------------- void ViewingParams::CenterOnParty() { - this->uMapBookMapZoom = (32768 * (__int64)this->uMapBookMapZoom) >> 16; + this->uMapBookMapZoom = fixpoint_mul(0x8000, this->uMapBookMapZoom); if (this->uMapBookMapZoom < 384) this->uMapBookMapZoom = 384;
--- a/mm7_2.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/mm7_2.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -1581,9 +1581,6 @@ //----- (0045063B) -------------------------------------------------------- int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) { - signed int v2; // edi@1 - Actor *v3; // esi@2 - //signed __int64 v4; // qax@3 int result; // eax@8 int v6; // edi@11 int v7; // ebx@11 @@ -1599,11 +1596,7 @@ int v17; // eax@20 int v18; // eax@21 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 - int v20; // [sp+24h] [bp-20h]@11 - //MapInfo *v21; // [sp+28h] [bp-1Ch]@1 int v22; // [sp+2Ch] [bp-18h]@3 - int v23; // [sp+30h] [bp-14h]@11 - //int v24; // [sp+34h] [bp-10h]@1 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 int v26; // [sp+3Ch] [bp-8h]@11 int v27; // [sp+40h] [bp-4h]@11 @@ -1611,27 +1604,85 @@ if (!uNumActors) return 0; - //v21 = a1; - //v24 = a2; - v2 = 0; - v3 = pActors.data(); - while ( 1 ) + for ( uint mon_id = 0; mon_id < uNumActors; ++mon_id ) { - if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C - v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C - v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C - !v3->CanAct()) + if ((pActors[mon_id].pMonsterInfo.uID < 121 || pActors[mon_id].pMonsterInfo.uID > 123) && // Dwarf FemaleC A-C + (pActors[mon_id].pMonsterInfo.uID < 124 || pActors[mon_id].pMonsterInfo.uID > 126) && // Dwarf MaleA A-C + (pActors[mon_id].pMonsterInfo.uID < 133 || pActors[mon_id].pMonsterInfo.uID > 135) && // Peasant Elf FemaleA A-C + pActors[mon_id].CanAct()) { - ++v2; - ++v3; - - if (v2 >= uNumActors) - return 0; - - continue; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + { + v22 = 0; + uint face_id = 0; + for ( face_id; face_id < 100; ++face_id ) + { + v6 = rand() % 1024 + 512; + v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; + v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v7), v6); + v8 = 0; + v19.uIndex = a2; + v19.vPosition.y = fixpoint_mul(stru_5C6E00->Sin(v7), v6) + pParty->vPosition.y; + v19.vPosition.z = pParty->vPosition.z; + v26 = 0; + v27 = 0; + v19.vPosition.z = ODM_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z, 0, &v26, &v27, 0); + for( int i = 0; i < pOutdoor->uNumBModels; i++ ) + { + v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); + v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); + if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) + { + v22 = 1; + break; + } + } + if ( v22 ) + { + v11 = face_id == 100; + break; + } + } + v11 = face_id == 100; + } + else if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + for ( uint i = 0; i < 100; ++i ) + { + v12 = rand() % 512 + 256; + v13 = rand(); + v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; + v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); + v19.vPosition.x = pParty->vPosition.x + fixpoint_mul(v15, v12); + v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); + v19.vPosition.y = fixpoint_mul(v16, v12) + pParty->vPosition.y; + v19.vPosition.z = pParty->vPosition.z; + v19.uIndex = a2; + v17 = pIndoor->GetSector(v19.vPosition.x, v19.vPosition.y, pParty->vPosition.z); + if ( v17 == v22 ) + { + v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); + v19.vPosition.z = v18; + if ( v18 != -30000 ) + { + if ( abs(v18 - pParty->vPosition.z) <= 1024 ) + break; + } + } + } + v11 = v26 == 100; + } + if ( v11 ) + result = 0; + else + { + SpawnEncounter(a1, &v19, 0, 0, 1); + result = a2; + } } - break; + //break; //v22 = v3->pMonsterInfo.uID - 1; //v4 = (signed __int64)((double)v22 * 0.3333333333333333); //if ( (int)v4 != 40 ) @@ -1644,99 +1695,6 @@ //if ( v2 >= (signed int)uNumActors ) // goto LABEL_8; } - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - { - v22 = 0; - uFaceID = 0; - while ( 1 ) - { - ++uFaceID; - v6 = rand() % 1024 + 512; - v7 = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; - v20 = stru_5C6E00->Cos(v7); - v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; - v19.vPosition.x = pParty->vPosition.x + v23; - v20 = stru_5C6E00->Sin(v7); - v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; - v8 = 0; - v19.uIndex = a2; - v19.vPosition.y = v23 + pParty->vPosition.y; - v19.vPosition.z = pParty->vPosition.z; - v26 = 0; - v27 = 0; - v19.vPosition.z = ODM_GetFloorLevel( - v19.vPosition.x, - v23 + pParty->vPosition.y, - pParty->vPosition.z, - 0, - &v26, - &v27, - 0); - v23 = 0; - for( int i = 0; i < pOutdoor->uNumBModels; i++ ) - { - v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); - v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); - if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) - { - v22 = 1; - break; - } - } - v11 = uFaceID == 100; - if ( uFaceID >= 100 ) - break; - if ( v22 ) - { - v11 = uFaceID == 100; - break; - } - } - } - else - { - v26 = 0; - v22 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - do - { - ++v26; - v12 = rand() % 512 + 256; - v13 = rand(); - v14 = v13 % (signed int)stru_5C6E00->uIntegerDoublePi; - v15 = stru_5C6E00->Cos(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); - v20 = v15; - v23 = (unsigned __int64)(v15 * (signed __int64)v12) >> 16; - v19.vPosition.x = pParty->vPosition.x + v23; - v16 = stru_5C6E00->Sin(v13 % (signed int)stru_5C6E00->uIntegerDoublePi); - v20 = v16; - v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; - v19.vPosition.y = v23 + pParty->vPosition.y; - v19.vPosition.z = pParty->vPosition.z; - v19.uIndex = a2; - v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); - if ( v17 == v22 ) - { - v18 = BLV_GetFloorLevel(v19.vPosition.x, v19.vPosition.y, v19.vPosition.z, v17, &uFaceID); - v19.vPosition.z = v18; - if ( v18 != -30000 ) - { - if ( abs(v18 - pParty->vPosition.z) <= 1024 ) - break; - } - } - } - while ( v26 < 100 ); - v11 = v26 == 100; - } - if ( v11 ) - { - result = 0; - } - else - { - SpawnEncounter(a1, &v19, 0, 0, 1); - result = a2; - } return result; }
--- a/mm7_3.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/mm7_3.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -455,7 +455,7 @@ v5 = (v10 * stru_721530.direction.y + v11 * stru_721530.direction.x) >> 16; if ( v5 > 0 ) { - v6 = ((unsigned __int64)(stru_721530.direction.z * (signed __int64)v5) >> 16) + stru_721530.normal.z; + v6 = fixpoint_mul(stru_721530.direction.z, v5) + stru_721530.normal.z; result = pParty->vPosition.z; if ( v6 >= pParty->vPosition.z ) { @@ -930,9 +930,9 @@ + face->pFacePlane.vNormal.z * pActors[v75].vPosition.z) >> 16); if ( v46 > 0 ) { - pActors[v75].vPosition.x += (unsigned int)(v46 * face->pFacePlane.vNormal.x) >> 16; - pActors[v75].vPosition.y += (unsigned int)(v46 * face->pFacePlane.vNormal.y) >> 16; - pActors[v75].vPosition.z += (unsigned int)(v46 * face->pFacePlane.vNormal.z) >> 16; + pActors[v75].vPosition.x += fixpoint_mul(v46, face->pFacePlane.vNormal.x); + pActors[v75].vPosition.y += fixpoint_mul(v46, face->pFacePlane.vNormal.y); + pActors[v75].vPosition.z += fixpoint_mul(v46, face->pFacePlane.vNormal.z); } pActors[v75].uYawAngle = stru_5C6E00->Atan2(pActors[v75].vVelocity.x, pActors[v75].vVelocity.y); } @@ -1122,7 +1122,7 @@ int v13; // esi@3 int v14; // edi@4 signed __int64 v15; // qtt@6 - __int16 v16; // si@7 + //__int16 v16; // si@7 int a7a; // [sp+30h] [bp+18h]@7 int a9b; // [sp+38h] [bp+20h]@3 int a9a; // [sp+38h] [bp+20h]@3 @@ -1132,9 +1132,9 @@ if ( a10 && face->Ethereal() ) return 0; - v11 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16; - a10b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16; - a9b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16; + v11 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x); + a10b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y); + a9b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z); v12 = v11 + a9b + a10b; a9a = v11 + a9b + a10b; v13 = (a1 << 16) @@ -1160,13 +1160,10 @@ a10a = 0; v14 = abs(v13) >> 16; } - v16 = pos_y + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_y) >> 16) >> 16); - LOWORD(a7a) = (short)pos_x - + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_x) >> 16) >> 16) - - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.x) >> 16); - HIWORD(a7a) = v16 - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.y) >> 16); - if ( !sub_475665(face, a7a, (short)pos_z + ((unsigned int)((unsigned __int64)(a10a * (signed __int64)dir_z) >> 16) >> 16) - - ((unsigned int)(v14 * face->pFacePlane_old.vNormal.z) >> 16)) ) + //v16 = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16); + LOWORD(a7a) = (short)pos_x + ((unsigned int)fixpoint_mul(a10a, dir_x) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.x); + HIWORD(a7a) = pos_y + ((unsigned int)fixpoint_mul(a10a, dir_y) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.y); + if ( !sub_475665(face, a7a, (short)pos_z + ((unsigned int)fixpoint_mul(a10a, dir_z) >> 16) - fixpoint_mul(v14, face->pFacePlane_old.vNormal.z)) ) return 0; *a2 = a10a >> 16; if ( a10a >> 16 < 0 ) @@ -1182,7 +1179,7 @@ int v14; // esi@3 int v15; // edi@4 signed __int64 v16; // qtt@6 - __int16 v17; // si@7 + //__int16 v17; // si@7 int a7a; // [sp+30h] [bp+18h]@7 int a1b; // [sp+38h] [bp+20h]@3 int a1a; // [sp+38h] [bp+20h]@3 @@ -1192,9 +1189,9 @@ if ( a11 && face->Ethereal() ) return false; - v12 = (unsigned __int64)(dir_x * (signed __int64)face->pFacePlane_old.vNormal.x) >> 16; - a11b = (unsigned __int64)(dir_y * (signed __int64)face->pFacePlane_old.vNormal.y) >> 16; - a1b = (unsigned __int64)(dir_z * (signed __int64)face->pFacePlane_old.vNormal.z) >> 16; + v12 = fixpoint_mul(dir_x, face->pFacePlane_old.vNormal.x); + a11b = fixpoint_mul(dir_y, face->pFacePlane_old.vNormal.y); + a1b = fixpoint_mul(dir_z, face->pFacePlane_old.vNormal.z); v13 = v12 + a1b + a11b; a1a = v12 + a1b + a11b; v14 = (a1 << 16) @@ -1220,13 +1217,10 @@ a11a = 0; v15 = abs(v14) >> 16; } - v17 = Y + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_y) >> 16) >> 16); - LOWORD(a7a) = (short)X - + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_x) >> 16) >> 16) - - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.x) >> 16); - HIWORD(a7a) = v17 - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.y) >> 16); - if ( !sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)((unsigned __int64)(a11a * (signed __int64)dir_z) >> 16) >> 16) - - ((unsigned int)(v15 * face->pFacePlane_old.vNormal.z) >> 16)) ) + //v17 = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16); + LOWORD(a7a) = (short)X + ((unsigned int)fixpoint_mul(a11a, dir_x) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.x); + HIWORD(a7a) = Y + ((unsigned int)fixpoint_mul(a11a, dir_y) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.y); + if ( !sub_4759C9(face, a10, a7a, (short)Z + ((unsigned int)fixpoint_mul(a11a, dir_z) >> 16) - fixpoint_mul(v15, face->pFacePlane_old.vNormal.z)) ) return false; *a2 = a11a >> 16; if ( a11a >> 16 < 0 ) @@ -1426,7 +1420,7 @@ || (word_720A70_intercepts_xs_plus_xs[v21] + ((signed int)(((unsigned __int64)(v19 / (word_7209A0_intercepts_ys_plus_ys[v21 + 1] - word_7209A0_intercepts_ys_plus_ys[v21]) * ((v24 - (signed int)word_7209A0_intercepts_ys_plus_ys[v21]) << 16)) >> 16) - + 32768) >> 16) >= v23) ) + + 0x8000) >> 16) >= v23) ) ++a4d; } } @@ -1461,13 +1455,12 @@ v4 = a4; v15 = a2; v14 = a1; - if ( BYTE3(a4->uAttributes) & 0x20 - || (v5 = (unsigned __int64)(a2->x * (signed __int64)a4->pFacePlane_old.vNormal.x) >> 16, - a4b = (unsigned __int64)(a2->y * (signed __int64)a4->pFacePlane_old.vNormal.y) >> 16, - v6 = (unsigned __int64)(a2->z * (signed __int64)v4->pFacePlane_old.vNormal.z) >> 16, - v7 = v5 + v6 + a4b, - (v16 = v5 + v6 + a4b) == 0) - || v7 > 0 && !v4->Portal()) + v5 = fixpoint_mul(a2->x, a4->pFacePlane_old.vNormal.x); + a4b = fixpoint_mul(a2->y, a4->pFacePlane_old.vNormal.y); + v6 = fixpoint_mul(a2->z, v4->pFacePlane_old.vNormal.z); + v7 = v5 + v6 + a4b; + //(v16 = v5 + v6 + a4b) == 0; + if ( a4->uAttributes & 0x20000000 || !v7 || v7 > 0 && !v4->Portal()) return 0; v8 = v4->pFacePlane_old.vNormal.z * a1->z; v9 = -(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x); @@ -1482,17 +1475,14 @@ return 0; } a4c = abs(-(v4->pFacePlane_old.dist + v8 + a1->y * v4->pFacePlane_old.vNormal.y + a1->x * v4->pFacePlane_old.vNormal.x)) >> 14; - if ( a4c > abs(v7) - || (LODWORD(v10) = v9 << 16, HIDWORD(v10) = v9 >> 16, a4a = v10 / v16, v17 = v10 / v16, v17 > *a3 << 16) - || (v11 = v14, - LOWORD(v12) = LOWORD(v14->x) - + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->x) >> 16) + 32768) >> 16), - HIWORD(v12) = LOWORD(v11->y) - + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->y) >> 16) + 32768) >> 16), - !sub_475665( - v4, - v12, - LOWORD(v11->z) + (((unsigned int)((unsigned __int64)(v17 * (signed __int64)v15->z) >> 16) + 32768) >> 16))) ) + v11 = v14; + LODWORD(v10) = v9 << 16; + HIDWORD(v10) = v9 >> 16; + a4a = v10 / v7; + v17 = v10 / v7; + LOWORD(v12) = LOWORD(v14->x) + (((unsigned int)fixpoint_mul(v17, v15->x) + 0x8000) >> 16); + HIWORD(v12) = LOWORD(v11->y) + (((unsigned int)fixpoint_mul(v17, v15->y) + 0x8000) >> 16); + if ( a4c > abs(v7) || ( v17 > *a3 << 16) || !sub_475665(v4, v12, LOWORD(v11->z) + (((unsigned int)fixpoint_mul(v17, v15->z) + 0x8000) >> 16)) ) return 0; *a3 = a4a >> 16; return 1; @@ -1504,7 +1494,7 @@ int v10; // ST20_4@2 int v11; // ST28_4@2 int v12; // ST24_4@2 - char v13; // zf@2 + int v13; // zf@2 int v14; // edi@2 signed int v16; // esi@5 int v17; // ST20_4@9 @@ -1514,15 +1504,13 @@ int v23; // [sp+1Ch] [bp-8h]@10 signed int v24; // [sp+20h] [bp-4h]@10 - if ( a2->Ethereal() - || (v10 = (unsigned __int64)(a6 * (signed __int64)a2->pFacePlane_old.vNormal.x) >> 16, - v11 = (unsigned __int64)(a7 * (signed __int64)a2->pFacePlane_old.vNormal.y) >> 16, - v12 = (unsigned __int64)(a8 * (signed __int64)a2->pFacePlane_old.vNormal.z) >> 16, - v13 = v10 + v12 + v11 == 0, - v14 = v10 + v12 + v11, - v22 = v10 + v12 + v11, - v13) - || v14 > 0 && !a2->Portal()) + v10 = fixpoint_mul(a6, a2->pFacePlane_old.vNormal.x); + v11 = fixpoint_mul(a7, a2->pFacePlane_old.vNormal.y); + v12 = fixpoint_mul(a8, a2->pFacePlane_old.vNormal.z); + v13 = v10 + v12 + v11; + v14 = v10 + v12 + v11; + v22 = v10 + v12 + v11; + if ( a2->Ethereal() || !v13 || v14 > 0 && !a2->Portal()) return 0; v16 = -(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z); if ( v14 <= 0 ) @@ -1536,12 +1524,13 @@ return 0; } v17 = abs(-(a2->pFacePlane_old.dist + a4 * a2->pFacePlane_old.vNormal.y + a3 * a2->pFacePlane_old.vNormal.x + a5 * a2->pFacePlane_old.vNormal.z)) >> 14; - if ( v17 > abs(v14) - || (LODWORD(v18) = v16 << 16, HIDWORD(v18) = v16 >> 16, v24 = v18 / v22, v23 = v18 / v22, v23 > *a1 << 16) - || (LOWORD(v19) = a3 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a6) >> 16) + 32768) >> 16), - HIWORD(v19) = a4 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a7) >> 16) + 32768) >> 16), - !sub_4759C9(a2, a9, v19, - a5 + (((unsigned int)((unsigned __int64)(v23 * (signed __int64)a8) >> 16) + 32768) >> 16))) ) + LODWORD(v18) = v16 << 16; + HIDWORD(v18) = v16 >> 16; + v24 = v18 / v22; + v23 = v18 / v22; + LOWORD(v19) = a3 + (((unsigned int)fixpoint_mul(v23, a6) + 0x8000) >> 16); + HIWORD(v19) = a4 + (((unsigned int)fixpoint_mul(v23, a7) + 0x8000) >> 16); + if ( v17 > abs(v14) || v23 > *a1 << 16 || !sub_4759C9(a2, a9, v19, a5 + (((unsigned int)fixpoint_mul(v23, a8) + 0x8000) >> 16)) ) return 0; *a1 = v24 >> 16; return 1; @@ -3338,7 +3327,7 @@ RenderBillboardTransform_local0 v10; // [sp+Ch] [bp-5Ch]@1 int v11; // [sp+5Ch] [bp-Ch]@6 int v12; // [sp+60h] [bp-8h]@1 - int v13; // [sp+64h] [bp-4h]@6 + //int v13; // [sp+64h] [bp-4h]@6 v10.sParentBillboardID = -1; v10.pTarget = pRenderer->pTargetSurface; @@ -3375,18 +3364,18 @@ //v7 = v6; v11 = pOtherOverlayList->pOverlays[i].field_E; //v13 = pFrame->scale; - v13 = (unsigned __int64)(v11 * (signed __int64)pFrame->scale) >> 16; + //v13 = fixpoint_mul(v11, pFrame->scale); v10.uScreenSpaceX = pOtherOverlayList->pOverlays[i].field_8; v10.uScreenSpaceY = pOtherOverlayList->pOverlays[i].field_A; - v10._screenspace_x_scaler_packedfloat = v13; - v10._screenspace_y_scaler_packedfloat = v13; + v10._screenspace_x_scaler_packedfloat = fixpoint_mul(v11, pFrame->scale); + v10._screenspace_y_scaler_packedfloat = fixpoint_mul(v11, pFrame->scale); v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(pFrame->uPaletteIndex, 0, 1); v8 = pOtherOverlayList->pOverlays[i].field_2; v10.sZValue = 0; v10.uFlags = 0; - v9 = pOverlayList->pOverlays[v8].uOverlayType; - if ( !v9 || v9 == 2 ) - v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[pFrame->pHwSpriteIDs[0]].uHeight >> 1; + //v9 = pOverlayList->pOverlays[v8].uOverlayType; + if ( !pOverlayList->pOverlays[v8].uOverlayType || pOverlayList->pOverlays[v8].uOverlayType == 2 ) + v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[pFrame->pHwSpriteIDs[0]].uHeight / 2; result = pSprites_LOD->pSpriteHeaders[pFrame->pHwSpriteIDs[0]]._4AD2D1(&v10, 0); ++v12; if ( v12 == 5 )
--- a/mm7_5.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/mm7_5.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -14,6 +14,7 @@ #include "Lights.h" #include "Level/Decoration.h" + //----- (004356FF) -------------------------------------------------------- void back_to_game() { @@ -286,9 +287,9 @@ a2a = 10; if ( !MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { - pVelocity->x = (unsigned __int64)(a2a * (signed __int64)pVelocity->x) >> 16; - pVelocity->y = (unsigned __int64)(a2a * (signed __int64)pVelocity->y) >> 16; - pVelocity->z = (unsigned __int64)(a2a * (signed __int64)pVelocity->z) >> 16; + pVelocity->x = fixpoint_mul(a2a, pVelocity->x); + pVelocity->y = fixpoint_mul(a2a, pVelocity->y); + pVelocity->z = fixpoint_mul(a2a, pVelocity->z); pActors[uActorID].vVelocity.x = 50 * LOWORD(pVelocity->x); pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); @@ -373,9 +374,9 @@ v18 = 10; if ( !MonsterStats::BelongsToSupertype(pActors[actor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { - pVelocity->x = (unsigned __int64)(v18 * (signed __int64)pVelocity->x) >> 16; - pVelocity->y = (unsigned __int64)(v18 * (signed __int64)pVelocity->y) >> 16; - pVelocity->z = (unsigned __int64)(v18 * (signed __int64)pVelocity->z) >> 16; + pVelocity->x = fixpoint_mul(v18, pVelocity->x); + pVelocity->y = fixpoint_mul(v18, pVelocity->y); + pVelocity->z = fixpoint_mul(v18, pVelocity->z); pActors[actor_id].vVelocity.x = 50 * LOWORD(pVelocity->x); pActors[actor_id].vVelocity.y = 50 * LOWORD(pVelocity->y); pActors[actor_id].vVelocity.z = 50 * LOWORD(pVelocity->z);
--- a/stru6.cpp Thu Feb 06 00:38:03 2014 +0600 +++ b/stru6.cpp Thu Feb 06 17:20:12 2014 +0600 @@ -477,12 +477,7 @@ //----- (004A7A27) -------------------------------------------------------- bool stru6::AddMobileLight(SpriteObject *a1, unsigned int uDiffuse, int uRadius) { - return pMobileLightsStack->AddLight( - a1->vPosition.x, - a1->vPosition.y, - a1->vPosition.z, - a1->uSectorID, - uRadius, + return pMobileLightsStack->AddLight(a1->vPosition.x, a1->vPosition.y, a1->vPosition.z, a1->uSectorID, uRadius, (uDiffuse & 0x00FF0000) >> 16, (uDiffuse & 0x0000FF00) >> 8, uDiffuse & 0x000000FF,