# HG changeset patch # User zipi # Date 1379442263 -3600 # Node ID 7182930263b366293013ceabd9a5bfab1bc65d03 # Parent 8971dc85b8fb7b20adb5b10e5c4a9a77239f39cd fixpoint functions renaming diff -r 8971dc85b8fb -r 7182930263b3 Actor.cpp --- a/Actor.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/Actor.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -3144,8 +3144,8 @@ v18 = -16; v7->uYawAngle = stru_5C6E00->Atan2( - pParty->vPosition.x + fixpoint_sub0(stru_5C6E00->Cos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.x, - pParty->vPosition.y + fixpoint_sub0(stru_5C6E00->Sin(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.y); + pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.x, + pParty->vPosition.y + fixpoint_mul(stru_5C6E00->Sin(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.y); if ( uActionLength ) v7->uCurrentActionLength = uActionLength; else diff -r 8971dc85b8fb -r 7182930263b3 CastSpellInfo.cpp --- a/CastSpellInfo.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/CastSpellInfo.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -1349,9 +1349,9 @@ else { v155 = stru_5C6E00->Cos(pParty->sRotationY); - uRequiredMana = pParty->vPosition.x + fixpoint_sub0(2048, v155); + uRequiredMana = pParty->vPosition.x + fixpoint_mul(2048, v155); v156 = stru_5C6E00->Sin(pParty->sRotationY); - LODWORD(v727) = pParty->vPosition.y + fixpoint_sub0(2048, v156); + LODWORD(v727) = pParty->vPosition.y + fixpoint_mul(2048, v156); v154 = pParty->vPosition.z; } unsigned __int64 k = 0; @@ -1656,9 +1656,9 @@ else { v212 = stru_5C6E00->Cos(pParty->sRotationY); - LODWORD(v718) = pParty->vPosition.x + fixpoint_sub0(2048, v212); + LODWORD(v718) = pParty->vPosition.x + fixpoint_mul(2048, v212); v213 = stru_5C6E00->Sin(pParty->sRotationY); - v214 = fixpoint_sub0(2048, v213); + v214 = fixpoint_mul(2048, v213); v211 = pParty->vPosition.z; v713 = pParty->vPosition.y + v214; v208 = LODWORD(v725); diff -r 8971dc85b8fb -r 7182930263b3 Indoor.cpp --- a/Indoor.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/Indoor.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -397,8 +397,8 @@ _this.field_0_timer = pEventTimer->uTotalGameTimeElapsed; //_this.fov_deg = 65; - //_this.vPosition.x = pParty->vPosition.x - fixpoint_sub0(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); - //_this.vPosition.y = pParty->vPosition.y - fixpoint_sub0(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); + //_this.vPosition.x = pParty->vPosition.x - fixpoint_mul(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); + //_this.vPosition.y = pParty->vPosition.y - fixpoint_mul(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); //_this.vPosition.z = pParty->vPosition.z + pParty->sEyelevel; //_this.sRotationX = pParty->sRotationX; //_this.sRotationY = pParty->sRotationY; @@ -2573,16 +2573,16 @@ HIDWORD(v33) = v32 >> 16;*/ //fixpoint_div(v1->x - v2->x, v1->y - v2->y); //_a58 = v33 / (v1->y - v2->y); - //_a59 = fixpoint_sub0(_a58, sY - v2->y); + //_a59 = fixpoint_mul(_a58, sY - v2->y); auto x_div_y = fixpoint_div(v1->x - v2->x, v1->y - v2->y); - auto res = fixpoint_sub0(x_div_y, sY - v2->y); // a / b * c - looks like projection + auto res = fixpoint_mul(x_div_y, sY - v2->y); // a / b * c - looks like projection if (res + v2->x > sX) ++v54; } else { auto x_div_y = fixpoint_div(v2->x - v1->x, v2->y - v1->y); - auto res = fixpoint_sub0(x_div_y, sY - v1->y); + auto res = fixpoint_mul(x_div_y, sY - v1->y); if (res + v1->x > sX) ++v54; @@ -2593,7 +2593,7 @@ LODWORD(v33) = v32 << 16; HIDWORD(v33) = v32 >> 16; _a58 = v33 / (v2->y - v1->y); - _a59 = fixpoint_sub0(_a58, sY - v1->y); + _a59 = fixpoint_mul(_a58, sY - v1->y); if (_a59 + pVertices[k].x > sX) ++v54;*/ @@ -3445,9 +3445,9 @@ } else { - v30 = v0->vPosition.x + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x); - v31 = v0->vPosition.y + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y); - v32 = v0->vPosition.z + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); + v30 = v0->vPosition.x + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); + v31 = v0->vPosition.y + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); + v32 = v0->vPosition.z + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); } v33 = collide_against_floor(v30, v31, v32, &stru_721530.uSectorID, &uFaceID); v34 = pIndoor->pFaces[uFaceID].uAttributes; @@ -3472,12 +3472,12 @@ goto LABEL_123; } //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16; - v0->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x); + v0->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16; - v0->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y); + v0->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); //v58 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16; v36 = stru_721530.uFaceID; - v0->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); + v0->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); v0->uSectorID = LOWORD(stru_721530.uSectorID); stru_721530.field_70 += stru_721530.field_7C; v37 = PID_ID(v36); @@ -3491,8 +3491,8 @@ v45 = stru_5C6E00->Atan2( v0->vPosition.x - pLevelDecorations[v37].vPosition.x, v0->vPosition.y - pLevelDecorations[v37].vPosition.y); - v0->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v45), _this); - v0->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v45), _this); + v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v45), _this); + v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v45), _this); goto LABEL_119; } if ( PID_TYPE(v36) == OBJECT_BModel) @@ -3521,9 +3521,9 @@ if ( (stru_721530.speed >> 3) > v61 ) v61 = stru_721530.speed >> 3; - v0->vVelocity.x += fixpoint_sub0(v61, v38->pFacePlane_old.vNormal.x); - v0->vVelocity.y += fixpoint_sub0(v61, v38->pFacePlane_old.vNormal.y); - v0->vVelocity.z += fixpoint_sub0(v61, v38->pFacePlane_old.vNormal.z); + v0->vVelocity.x += fixpoint_mul(v61, v38->pFacePlane_old.vNormal.x); + v0->vVelocity.y += fixpoint_mul(v61, v38->pFacePlane_old.vNormal.y); + v0->vVelocity.z += fixpoint_mul(v61, v38->pFacePlane_old.vNormal.z); v41 = v38->uPolygonType; if ( v41 != 4 && v41 != 3 ) { @@ -3547,9 +3547,9 @@ EventProcessor(pIndoor->pFaceExtras[v38->uFaceExtraID].uEventID, 0, 1); } LABEL_119: - v0->vVelocity.x = fixpoint_sub0(58500, v0->vVelocity.x); - v0->vVelocity.y = fixpoint_sub0(58500, v0->vVelocity.y); - v0->vVelocity.z = fixpoint_sub0(58500, v0->vVelocity.z); + v0->vVelocity.x = fixpoint_mul(58500, v0->vVelocity.x); + v0->vVelocity.y = fixpoint_mul(58500, v0->vVelocity.y); + v0->vVelocity.z = fixpoint_mul(58500, v0->vVelocity.z); v22 = 0; goto LABEL_120; } @@ -4070,7 +4070,7 @@ else { auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - auto res = fixpoint_sub0((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); + auto res = fixpoint_mul((signed int)word_721460_xs[j + 1] - (signed int)word_721460_xs[j], a_div_b); if (res + word_721460_xs[j] >= x) ++v53; @@ -4088,7 +4088,7 @@ } else { - v21 = fixpoint_sub0(pFloor->zCalc1, x) + fixpoint_sub0(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); + v21 = fixpoint_mul(pFloor->zCalc1, x) + fixpoint_mul(pFloor->zCalc2, y) + (short)(pFloor->zCalc3 >> 16); } blv_floor_level[v55] = v21; blv_floor_id[v55] = pSector->pFloors[i]; @@ -4141,7 +4141,7 @@ else { auto a_div_b = fixpoint_div(y - word_721390_ys[j], word_721390_ys[j + 1] - word_721390_ys[j]); - auto res = fixpoint_sub0(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); + auto res = fixpoint_mul(word_721460_xs[j + 1] - word_721460_xs[j], a_div_b); if (res + word_721460_xs[j] >= x) ++v54; } @@ -5164,9 +5164,9 @@ { v16 = v8 * -pGame->pIndoorCameraD3D->vPartyPos.x + v29 * -pGame->pIndoorCameraD3D->vPartyPos.y; v17 = -65536 * pGame->pIndoorCameraD3D->vPartyPos.z; - this->field_0_party_dir_x = fixpoint_sub0(v16, v28) + fixpoint_sub0((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v9); + this->field_0_party_dir_x = fixpoint_mul(v16, v28) + fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v9); this->field_4_party_dir_y = v8 * -pGame->pIndoorCameraD3D->vPartyPos.y - v29 * -pGame->pIndoorCameraD3D->vPartyPos.x; - this->field_8_party_dir_z = fixpoint_sub0(v17, v28) - fixpoint_sub0(v16, v9); + this->field_8_party_dir_z = fixpoint_mul(v17, v28) - fixpoint_mul(v16, v9); } else { @@ -5177,31 +5177,31 @@ if (pGame->pIndoorCameraD3D->sRotationX) { - v19 = fixpoint_sub0(a2, v8) + fixpoint_sub0(a3, v29); - - this->field_C = fixpoint_sub0(v19, v28) + fixpoint_sub0(a4, v9); - this->field_10 = fixpoint_sub0(a3, v8) - fixpoint_sub0(a2, v29); - this->field_14 = fixpoint_sub0(a4, v28) - fixpoint_sub0(v19, v9); + v19 = fixpoint_mul(a2, v8) + fixpoint_mul(a3, v29); + + this->field_C = fixpoint_mul(v19, v28) + fixpoint_mul(a4, v9); + this->field_10 = fixpoint_mul(a3, v8) - fixpoint_mul(a2, v29); + this->field_14 = fixpoint_mul(a4, v28) - fixpoint_mul(v19, v9); } else { - this->field_C = fixpoint_sub0(a2, v8) + fixpoint_sub0(a3, v29); - this->field_10 = fixpoint_sub0(a3, v8) - fixpoint_sub0(a2, v29); + this->field_C = fixpoint_mul(a2, v8) + fixpoint_mul(a3, v29); + this->field_10 = fixpoint_mul(a3, v8) - fixpoint_mul(a2, v29); this->field_14 = a4; } if (pGame->pIndoorCameraD3D->sRotationX) { - v21 = fixpoint_sub0(a5, v8) + fixpoint_sub0(a6, v29); - - this->field_18 = fixpoint_sub0(v21, v28) + fixpoint_sub0(a7, v9); - this->field_1C = fixpoint_sub0(a6, v8) - fixpoint_sub0(a5, v29); - this->field_20 = fixpoint_sub0(a7, v28) - fixpoint_sub0(v21, v9); + v21 = fixpoint_mul(a5, v8) + fixpoint_mul(a6, v29); + + this->field_18 = fixpoint_mul(v21, v28) + fixpoint_mul(a7, v9); + this->field_1C = fixpoint_mul(a6, v8) - fixpoint_mul(a5, v29); + this->field_20 = fixpoint_mul(a7, v28) - fixpoint_mul(v21, v9); } else { - this->field_18 = fixpoint_sub0(a5, v8) + fixpoint_sub0(a6, v29); - this->field_1C = fixpoint_sub0(a6, v8) - fixpoint_sub0(a5, v29); + this->field_18 = fixpoint_mul(a5, v8) + fixpoint_mul(a6, v29); + this->field_1C = fixpoint_mul(a6, v8) - fixpoint_mul(a5, v29); this->field_20 = a7; } @@ -5535,9 +5535,9 @@ if ( v108 >= 0 ) { if ( sub_4075DB( - pOut.x + ((signed int)(fixpoint_sub0(v108, v143) + 32768) >> 16), - pOut.y + ((signed int)(fixpoint_sub0(v108, v147) + 32768) >> 16), - outz + ((signed int)(fixpoint_sub0(v108, v151) + 32768) >> 16), + pOut.x + ((signed int)(fixpoint_mul(v108, v143) + 32768) >> 16), + pOut.y + ((signed int)(fixpoint_mul(v108, v147) + 32768) >> 16), + outz + ((signed int)(fixpoint_mul(v108, v151) + 32768) >> 16), v62) ) { v114 = 1; @@ -5661,9 +5661,9 @@ || v132 < v90->pBounding.y1 || v136 > v90->pBounding.z2 || v140 < v90->pBounding.z1 - || (yb = fixpoint_sub0(v144, v90->pFacePlane_old.vNormal.x), - v_4b = fixpoint_sub0(v148, v90->pFacePlane_old.vNormal.y), - vf = fixpoint_sub0(v152, v90->pFacePlane_old.vNormal.z), + || (yb = fixpoint_mul(v144, v90->pFacePlane_old.vNormal.x), + v_4b = fixpoint_mul(v148, v90->pFacePlane_old.vNormal.y), + vf = fixpoint_mul(v152, v90->pFacePlane_old.vNormal.z), v20 = yb + vf + v_4b == 0, v91 = yb + vf + v_4b, vc = yb + vf + v_4b, @@ -5704,9 +5704,9 @@ if ( vd >= 0 ) { if ( sub_4075DB( - pOut.x + ((signed int)(fixpoint_sub0(vd, v144) + 32768) >> 16), - pOut.y + ((signed int)(fixpoint_sub0(vd, v148) + 32768) >> 16), - outz + ((signed int)(fixpoint_sub0(vd, v152) + 32768) >> 16), + pOut.x + ((signed int)(fixpoint_mul(vd, v144) + 32768) >> 16), + pOut.y + ((signed int)(fixpoint_mul(vd, v148) + 32768) >> 16), + outz + ((signed int)(fixpoint_mul(vd, v152) + 32768) >> 16), v90) ) { v113 = 1; @@ -5804,9 +5804,9 @@ || v137 < v16->pBoundingBox.y1 || v133 > v16->pBoundingBox.z2 || v129 < v16->pBoundingBox.z1 - || (v17 = fixpoint_sub0(v125, v16->pFacePlane.vNormal.x), - v18 = fixpoint_sub0(v121, v16->pFacePlane.vNormal.y), - v19 = fixpoint_sub0(v117, v16->pFacePlane.vNormal.z), + || (v17 = fixpoint_mul(v125, v16->pFacePlane.vNormal.x), + v18 = fixpoint_mul(v121, v16->pFacePlane.vNormal.y), + v19 = fixpoint_mul(v117, v16->pFacePlane.vNormal.z), v20 = v17 + v18 + v19 == 0, v21 = v17 + v18 + v19, v109 = v17 + v18 + v19, @@ -5835,9 +5835,9 @@ if ( v110 >= 0 ) { if ( sub_4077F1( - pOut.x + ((signed int)(fixpoint_sub0(v110, v125) + 32768) >> 16), - pOut.y + ((signed int)(fixpoint_sub0(v110, v121) + 32768) >> 16), - outz + ((signed int)(fixpoint_sub0(v110, v117) + 32768) >> 16), + pOut.x + ((signed int)(fixpoint_mul(v110, v125) + 32768) >> 16), + pOut.y + ((signed int)(fixpoint_mul(v110, v121) + 32768) >> 16), + outz + ((signed int)(fixpoint_mul(v110, v117) + 32768) >> 16), v16, (BSPVertexBuffer *)a5) ) { @@ -5938,9 +5938,9 @@ || v138 < v39->pBoundingBox.y1 || v134 > v39->pBoundingBox.z2 || v130 < v39->pBoundingBox.z1 - || (ya = fixpoint_sub0(v126, v39->pFacePlane.vNormal.x), - ve = fixpoint_sub0(v122, v39->pFacePlane.vNormal.y), - v_4 = fixpoint_sub0(v118, v39->pFacePlane.vNormal.z), + || (ya = fixpoint_mul(v126, v39->pFacePlane.vNormal.x), + ve = fixpoint_mul(v122, v39->pFacePlane.vNormal.y), + v_4 = fixpoint_mul(v118, v39->pFacePlane.vNormal.z), v20 = ya + ve + v_4 == 0, v40 = ya + ve + v_4, va = ya + ve + v_4, @@ -5968,9 +5968,9 @@ if ( vb >= 0 ) { if ( sub_4077F1( - pOut.x + ((signed int)(fixpoint_sub0(vb, v126) + 32768) >> 16), - pOut.y + ((signed int)(fixpoint_sub0(vb, v122) + 32768) >> 16), - outz + ((signed int)(fixpoint_sub0(vb, v118) + 32768) >> 16), + pOut.x + ((signed int)(fixpoint_mul(vb, v126) + 32768) >> 16), + pOut.y + ((signed int)(fixpoint_mul(vb, v122) + 32768) >> 16), + outz + ((signed int)(fixpoint_mul(vb, v118) + 32768) >> 16), v39, (BSPVertexBuffer *)a5a) ) { diff -r 8971dc85b8fb -r 7182930263b3 Math.h --- a/Math.h Tue Sep 17 20:15:56 2013 +0200 +++ b/Math.h Tue Sep 17 19:24:23 2013 +0100 @@ -24,11 +24,10 @@ }; #pragma pack(pop) -__int64 fixpoint_sub0(int, int); -__int64 fixpoint_sub2(int, int); +__int64 fixpoint_mul(int, int); __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2); __int64 fixpoint_div(int, int); -__int64 fixpoint_mul(int, int); +__int64 fixpoint_sub_unknown(int, int); int fixpoint_from_float(float value); int fixpoint_from_int(int lhv, int rhv); diff -r 8971dc85b8fb -r 7182930263b3 ParticleEngine.cpp --- a/ParticleEngine.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/ParticleEngine.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -415,7 +415,7 @@ //uParticleID = v44 >> 16; LODWORD(v44) = (signed int)(v44 >> 16) >> 16; pParticle->uScreenSpaceY = pBLVRenderParams->uViewportCenterY - v44; - pParticle->_screenspace_scale = fixpoint_sub0(fixpoint_from_float(pParticle->flt_28), pParticle->_screenspace_scale); + pParticle->_screenspace_scale = fixpoint_mul(fixpoint_from_float(pParticle->flt_28), pParticle->_screenspace_scale); pParticle->sZValue = z; return true; } @@ -442,7 +442,7 @@ //v7 = pParticle->flt_28; //pParticle->_screenspace_scale = v6 / x; //v8 = v7; - pParticle->_screenspace_scale = fixpoint_sub0(fixpoint_from_float(pParticle->flt_28), v6 / x); + pParticle->_screenspace_scale = fixpoint_mul(fixpoint_from_float(pParticle->flt_28), v6 / x); pParticle->sZValue = x; return true; } @@ -527,11 +527,11 @@ //uIDc = (LODWORD(v8) - pIndoorCamera->pos.x) << 16; //v9 = v6->_y + 6.7553994e15; //v10 = (LODWORD(v9) - pIndoorCamera->pos.y) << 16; - v11 = fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); - //HIDWORD(v8) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); + v11 = fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(v6->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; - auto _hidword_v12 = fixpoint_sub0(v11, v3) + fixpoint_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44); + auto _hidword_v12 = fixpoint_mul(v11, v3) + fixpoint_sub_unknown(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44); LODWORD(v13) = 0; HIDWORD(v13) = SLOWORD(pODMRenderParams->int_fov_rad); //v14 = v13 / _hidword_v12; @@ -539,24 +539,24 @@ //v15 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v6->_screenspace_scale - * (signed __int64)(fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16) >> 16); + * (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_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) + * (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; } //uIDe = (v41 - pIndoorCamera->pos.x) << 16; //v47 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; - v45 = fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); - //HIDWORD(v42) = fixpoint_mul(v6->x - pIndoorCamera->pos.x, v5); + v45 = fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(v6->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_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_sub0(v45, v3); + X_4 = fixpoint_sub_unknown(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v44) + fixpoint_mul(v45, v3); if ( X_4 < 0x40000 ) return 0; - v16 = fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); - v17 = fixpoint_mul(v6->z - pGame->pIndoorCameraD3D->vPartyPos.z, v3) - fixpoint_sub0(v45, v44); + 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); } else { @@ -569,26 +569,26 @@ //v21 = v6->_z + 6.7553994e15; LODWORD(v22) = 0; HIDWORD(v22) = SLOWORD(pODMRenderParams->int_fov_rad); - auto _var_123 = fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); + auto _var_123 = fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4) + fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); //v23 = v22 / _var_123; v6->_screenspace_scale = v22 / _var_123; //v24 = v6->_screenspace_scale; v6->uScreenSpaceX = pViewport->uScreenCenterX - ((signed int)((unsigned __int64)(v6->_screenspace_scale - * (signed __int64)(fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5))) >> 16) >> 16); - v6->uScreenSpaceY = pViewport->uScreenCenterY - (fixpoint_mul(v6->z, v6->_screenspace_scale) >> 16); + * (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; } //uIDb = (v41 - pIndoorCamera->pos.x) << 16; //v48 = (LODWORD(v39) - pIndoorCamera->pos.y) << 16; - v26 = fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); + v26 = fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v5); //v27 = v26 + ((unsigned __int64)(uIDb * (signed __int64)v4) >> 16); - X_4 = v26 + fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4); + X_4 = v26 + fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v4); if ( X_4 < 0x40000 || X_4 > (pODMRenderParams->uPickDepth - 1000) << 16 ) return 0; v17 = v6->z; - v16 = fixpoint_mul(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - fixpoint_mul(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); + v16 = fixpoint_sub_unknown(v6->y - pGame->pIndoorCameraD3D->vPartyPos.y, v4) - fixpoint_sub_unknown(v6->x - pGame->pIndoorCameraD3D->vPartyPos.x, v5); } v40 = v17; v28 = abs(v16); @@ -604,7 +604,7 @@ v33 = (signed int)((unsigned __int64)(v6->_screenspace_scale * (signed __int64)v40) >> 16) >> 16; //v34 = pViewport->uScreenCenterY - v33; v6->uScreenSpaceY = pViewport->uScreenCenterY - v33; - v6->_screenspace_scale = fixpoint_sub0(fixpoint_from_float(v6->flt_28), v6->_screenspace_scale); + 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 ) diff -r 8971dc85b8fb -r 7182930263b3 SpriteObject.cpp --- a/SpriteObject.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/SpriteObject.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -82,11 +82,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); + v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); } else { @@ -107,11 +107,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); + v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); } else { @@ -132,11 +132,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)) >> 16; - a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)) >> 16; - pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); + v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)) >> 16; + a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); } else { @@ -157,11 +157,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); + v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); } else { @@ -182,11 +182,11 @@ pSpriteObjects[v6].vVelocity.z = 0; if ( a4 ) { - v13 = fixpoint_sub0(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); - a5a = fixpoint_sub0(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); - pSpriteObjects[v6].vVelocity.x = fixpoint_sub0(v13, a4); - pSpriteObjects[v6].vVelocity.y = fixpoint_sub0(a5a, a4); - pSpriteObjects[v6].vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(pitch), a4); + v13 = fixpoint_mul(stru_5C6E00->Cos(angle), stru_5C6E00->Cos(pitch)); + a5a = fixpoint_mul(stru_5C6E00->Sin(angle), stru_5C6E00->Cos(pitch)); + pSpriteObjects[v6].vVelocity.x = fixpoint_mul(v13, a4); + pSpriteObjects[v6].vVelocity.y = fixpoint_mul(a5a, a4); + pSpriteObjects[v6].vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(pitch), a4); } else { @@ -311,11 +311,11 @@ v1->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); v56 = abs(v51.y * v1->vVelocity.y + v51.z * v1->vVelocity.z + v51.x * v1->vVelocity.x) >> 16; //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.x) >> 16); - v1->vVelocity.x += fixpoint_sub0(v56, v51.x); + v1->vVelocity.x += fixpoint_mul(v56, v51.x); //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.y) >> 16); - v1->vVelocity.y += fixpoint_sub0(v56, v51.y); + v1->vVelocity.y += fixpoint_mul(v56, v51.y); //v60 = ((unsigned __int64)(v56 * (signed __int64)v51.z) >> 16); - v1->vVelocity.z += fixpoint_sub0(v56, v51.z); + v1->vVelocity.z += fixpoint_mul(v56, v51.z); LABEL_12: v7 = v54; goto LABEL_13; @@ -331,9 +331,9 @@ if ( !(v2->uFlags & OBJECT_DESC_BOUNCE) || (v21 = -v1->vVelocity.z >> 1, v1->vVelocity.z = v21, (signed __int16)v21 < 10) ) v1->vVelocity.z = 0; - v1->vVelocity.x = fixpoint_sub0(58500, v1->vVelocity.x); - v1->vVelocity.y = fixpoint_sub0(58500, v1->vVelocity.y); - v1->vVelocity.z = fixpoint_sub0(58500, v1->vVelocity.z); + v1->vVelocity.x = fixpoint_mul(58500, v1->vVelocity.x); + v1->vVelocity.y = fixpoint_mul(58500, v1->vVelocity.y); + v1->vVelocity.z = fixpoint_mul(58500, v1->vVelocity.z); if ( (v1->vVelocity.y * v1->vVelocity.y + v1->vVelocity.x * v1->vVelocity.x) < 400 ) { @@ -503,12 +503,12 @@ return; } //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16); - v1->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x); + v1->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16); - v1->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y); + v1->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); //v60 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16); v28 = LOWORD(stru_721530.uSectorID); - v1->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); + v1->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); v29 = v1->vPosition.z; v1->uSectorID = v28; stru_721530.field_70 += stru_721530.field_7C; @@ -786,11 +786,11 @@ return; } //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.x) >> 16; - pSpriteObject->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x); + pSpriteObject->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.y) >> 16; - pSpriteObject->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y); + pSpriteObject->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); //v40 = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.direction.z) >> 16; - pSpriteObject->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); + pSpriteObject->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); pSpriteObject->uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) ) @@ -801,8 +801,8 @@ v40 = integer_sqrt(pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y); v23 = stru_5C6E00->Atan2(pSpriteObject->vPosition.x - pLevelDecorations[v15].vPosition.x, pSpriteObject->vPosition.y - pLevelDecorations[v15].vPosition.y); - pSpriteObject->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v23), v40); - pSpriteObject->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v23), v40); + pSpriteObject->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v23), v40); + pSpriteObject->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v23), v40); } else { @@ -816,9 +816,9 @@ + v16->pFacePlane_old.vNormal.y * pSpriteObject->vVelocity.y) >> 16; if ( (stru_721530.speed >> 3) > v42 ) v42 = stru_721530.speed >> 3; - pSpriteObject->vVelocity.x += 2 * fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.x); - pSpriteObject->vVelocity.y += 2 * fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.y); - v39 = fixpoint_sub0(v42, v16->pFacePlane_old.vNormal.z); + pSpriteObject->vVelocity.x += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.x); + pSpriteObject->vVelocity.y += 2 * fixpoint_mul(v42, v16->pFacePlane_old.vNormal.y); + v39 = fixpoint_mul(v42, v16->pFacePlane_old.vNormal.z); if ( v16->pFacePlane_old.vNormal.z <= 32000 ) { v22 = 2 * v39; @@ -826,7 +826,7 @@ else { pSpriteObject->vVelocity.z += v39; - v22 = fixpoint_sub0(32000, v39); + v22 = fixpoint_mul(32000, v39); } pSpriteObject->vVelocity.z += v22; if ( BYTE3(v16->uAttributes) & 0x10 ) @@ -861,9 +861,9 @@ LABEL_63: //v2 = v37; LABEL_64: - pSpriteObject->vVelocity.x = fixpoint_sub0(58500, pSpriteObject->vVelocity.x); - pSpriteObject->vVelocity.y = fixpoint_sub0(58500, pSpriteObject->vVelocity.y); - pSpriteObject->vVelocity.z = fixpoint_sub0(58500, pSpriteObject->vVelocity.z); + pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x); + pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y); + pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z); ++uFaceID; v28 = __OFSUB__(uFaceID, 100); v27 = uFaceID - 100 < 0; @@ -893,9 +893,9 @@ pSpriteObject->vVelocity.z -= LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); v8 = 0; } - pSpriteObject->vVelocity.x = fixpoint_sub0(58500, pSpriteObject->vVelocity.x); - pSpriteObject->vVelocity.y = fixpoint_sub0(58500, pSpriteObject->vVelocity.y); - pSpriteObject->vVelocity.z = fixpoint_sub0(58500, pSpriteObject->vVelocity.z); + pSpriteObject->vVelocity.x = fixpoint_mul(58500, pSpriteObject->vVelocity.x); + pSpriteObject->vVelocity.y = fixpoint_mul(58500, pSpriteObject->vVelocity.y); + pSpriteObject->vVelocity.z = fixpoint_mul(58500, pSpriteObject->vVelocity.z); v9 = pSpriteObject->vVelocity.x; if ( v9 * v9 + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y < 400 ) { diff -r 8971dc85b8fb -r 7182930263b3 Viewport.cpp --- a/Viewport.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/Viewport.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -54,7 +54,7 @@ this->uScreenHeight = br_y - tl_y + 1; this->uScreenCenterX = (signed int)(br_x + tl_x) /2; if ( pRenderer->pRenderD3D == 0 ) - this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_sub0(field_30, uScreenHeight); + this->uScreenCenterY = this->uScreen_BR_Y - fixpoint_mul(field_30, uScreenHeight); else this->uScreenCenterY = uScreenHeight/2; SetViewport(this->uScreen_TL_X, this->uScreen_TL_Y, this->uScreen_BR_X, this->uScreen_BR_Y); diff -r 8971dc85b8fb -r 7182930263b3 mm7_1.cpp --- a/mm7_1.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/mm7_1.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -52,7 +52,7 @@ return ((__int64)a1 << 16) / a2; } -__int64 fixpoint_mul(int a1, int a2) +__int64 fixpoint_sub_unknown(int a1, int a2) { return (((__int64)a1 << 16) * a2) >> 16; } @@ -61,24 +61,16 @@ //----- (0042EBBE) -------------------------------------------------------- //----- (004453C0) mm6----------------------------------------------------- //----- (004A1760) mm6_chinese--------------------------------------------- -__int64 fixpoint_sub0(int a1, int a2) +__int64 fixpoint_mul(int a1, int a2) { return ((__int64)a1 * (__int64)a2) >> 16; } -__int64 fixpoint_sub2(int a1, int a2) -{ - signed __int64 v3; // qtt@1 - - LODWORD(v3) = a1 << 16; - HIDWORD(v3) = a1 >> 16; - return v3 / a2; -} __int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2) { - return fixpoint_sub0(x1, x2) + - fixpoint_sub0(y1, y2) + - fixpoint_sub0(z1, z2); + return fixpoint_mul(x1, x2) + + fixpoint_mul(y1, y2) + + fixpoint_mul(z1, z2); } //----- (0041D20D) -------------------------------------------------------- diff -r 8971dc85b8fb -r 7182930263b3 mm7_2.cpp --- a/mm7_2.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/mm7_2.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -1343,15 +1343,15 @@ v6->pMonsterInfo.uExp = 0; v6->uMovementSpeed = v9; v10 = rand() % 2048; - //v11 = pParty->vPosition.x + fixpoint_sub0(stru_5C6E00->Cos(v10), v19); + //v11 = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); uFaceID = stru_5C6E00->Sin(v10); //v12 = pParty->vPosition.y; - //v13 = fixpoint_sub0(uFaceID, v19); - //v14 = pParty->vPosition.y + fixpoint_sub0(uFaceID, v19); + //v13 = fixpoint_mul(uFaceID, v19); + //v14 = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); //LOWORD(v12) = v22; - v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_sub0(stru_5C6E00->Cos(v10), v19); + v6->vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); v6->vPosition.x = v6->vInitialPosition.x; - v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_sub0(uFaceID, v19); + v6->vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(uFaceID, v19); v6->vPosition.y = v6->vInitialPosition.y; v6->vInitialPosition.z = pParty->vPosition.z; v6->vPosition.z = v6->vInitialPosition.z; diff -r 8971dc85b8fb -r 7182930263b3 mm7_3.cpp --- a/mm7_3.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/mm7_3.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -794,22 +794,22 @@ else v7 = pEventTimer->dt_in_some_format; - v8 = fixpoint_sub0(v7, speed) - v2->field_70; // speed * dt - something + v8 = fixpoint_mul(v7, speed) - v2->field_70; // speed * dt - something v2->field_6C = v8; if ( v8 > 0 ) { - v10 = fixpoint_sub0(v8, v2->direction.x) + v2->normal.x; + v10 = fixpoint_mul(v8, v2->direction.x) + v2->normal.x; v2->field_4C = v10; v2->normal2.x = v10; - v11 = fixpoint_sub0(v2->field_6C, v2->direction.y) + v2->normal.y; + v11 = fixpoint_mul(v2->field_6C, v2->direction.y) + v2->normal.y; v2->field_50 = v11; v2->normal2.y = v11; - v2->normal2.z = fixpoint_sub0(v2->field_6C, v2->direction.z) + v2->normal.z; + v2->normal2.z = fixpoint_mul(v2->field_6C, v2->direction.z) + v2->normal.z; v12 = v2->position.z; v13 = v2->normal.x; v14 = v2->normal2.x; v15 = v2->prolly_normal_d; - v16 = v12 + fixpoint_sub0(v2->field_6C, v2->direction.z); + v16 = v12 + fixpoint_mul(v2->field_6C, v2->direction.z); v28 = v16; v2->field_54 = v16; v17 = v13; @@ -991,21 +991,21 @@ if ( v8 > 1000 ) v8 = 1000; - v0->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v0->uYawAngle), v8); - v0->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v0->uYawAngle), v8); + v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v0->uYawAngle), v8); + v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v0->uYawAngle), v8); if ( uIsFlying ) { - v0->vVelocity.z = fixpoint_sub0(stru_5C6E00->Sin(v0->uPitchAngle), v8); + v0->vVelocity.z = fixpoint_mul(stru_5C6E00->Sin(v0->uPitchAngle), v8); } //v7 = v68; } else { - v0->vVelocity.x = fixpoint_sub0(55000, v0->vVelocity.x); - v0->vVelocity.y = fixpoint_sub0(55000, v0->vVelocity.y); + v0->vVelocity.x = fixpoint_mul(55000, v0->vVelocity.x); + v0->vVelocity.y = fixpoint_mul(55000, v0->vVelocity.y); if ( uIsFlying ) { - v0->vVelocity.z = fixpoint_sub0(55000, v0->vVelocity.z); + v0->vVelocity.z = fixpoint_mul(55000, v0->vVelocity.z); } } if ( v0->vPosition.z < v5 ) @@ -1028,9 +1028,9 @@ v0->vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * v20; int v73 = abs(v62.x * v0->vVelocity.x + v62.z * v0->vVelocity.z + v62.y * v0->vVelocity.y) >> 16; //v72b = v21; - v0->vVelocity.x += fixpoint_sub0(v73, v62.x); - v0->vVelocity.y += fixpoint_sub0(v73, v62.y); - v0->vVelocity.z += fixpoint_sub0(v73, v62.z); + v0->vVelocity.x += fixpoint_mul(v73, v62.x); + v0->vVelocity.y += fixpoint_mul(v73, v62.y); + v0->vVelocity.z += fixpoint_mul(v73, v62.z); //v17 = 0; } } @@ -1097,7 +1097,7 @@ } v71 = i > 1; if ( stru_721530.field_7C < stru_721530.field_6C ) - v70 = fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); + v70 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); //v34 = 0; v35 = stru_721530.normal2.z - stru_721530.prolly_normal_d - 1; v36 = ODM_GetFloorLevel(stru_721530.normal2.x, @@ -1130,12 +1130,12 @@ v0->vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; break; } - //v72b = fixpoint_sub0(stru_721530.field_7C, stru_721530.field_58.x); - v0->vPosition.x += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x); + //v72b = fixpoint_mul(stru_721530.field_7C, stru_721530.field_58.x); + v0->vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16; - v0->vPosition.y += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y); + v0->vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); //v72b = (unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16; - v0->vPosition.z += fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); + v0->vPosition.z += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); v38 = stru_721530.uFaceID; stru_721530.field_70 += stru_721530.field_7C; v39 = PID_ID(v38); @@ -1193,8 +1193,8 @@ v0->vPosition.x - pLevelDecorations[v39].vPosition.x, v0->vPosition.y - pLevelDecorations[v39].vPosition.y); v49 = v48; - v0->vVelocity.x = fixpoint_sub0(stru_5C6E00->Cos(v48), v47); - v0->vVelocity.y = fixpoint_sub0(stru_5C6E00->Sin(v48), v47); + v0->vVelocity.x = fixpoint_mul(stru_5C6E00->Cos(v48), v47); + v0->vVelocity.y = fixpoint_mul(stru_5C6E00->Sin(v48), v47); break; case OBJECT_BModel: v40 = &pOutdoor->pBModels[v38 >> 9]; @@ -1221,9 +1221,9 @@ if ( (stru_721530.speed >> 3) > v72b ) v72b = stru_721530.speed >> 3; - v0->vVelocity.x += fixpoint_sub0(v72b, v41->pFacePlane.vNormal.x); - v0->vVelocity.y += fixpoint_sub0(v72b, v41->pFacePlane.vNormal.y); - v0->vVelocity.z += fixpoint_sub0(v72b, v41->pFacePlane.vNormal.z); + v0->vVelocity.x += fixpoint_mul(v72b, v41->pFacePlane.vNormal.x); + v0->vVelocity.y += fixpoint_mul(v72b, v41->pFacePlane.vNormal.y); + v0->vVelocity.z += fixpoint_mul(v72b, v41->pFacePlane.vNormal.z); if ( v42 != 4 ) { v45 = v0->vPosition.z; @@ -1245,9 +1245,9 @@ break; } - v0->vVelocity.x = fixpoint_sub0(58500, v0->vVelocity.x); - v0->vVelocity.y = fixpoint_sub0(58500, v0->vVelocity.y); - v0->vVelocity.z = fixpoint_sub0(58500, v0->vVelocity.z); + v0->vVelocity.x = fixpoint_mul(58500, v0->vVelocity.x); + v0->vVelocity.y = fixpoint_mul(58500, v0->vVelocity.y); + v0->vVelocity.z = fixpoint_mul(58500, v0->vVelocity.z); ++v69; if ( v69 >= 100 ) @@ -1696,37 +1696,37 @@ break; case PARTY_StrafeLeft: - v2 -= fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2); - v1 += fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2); + v2 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2); + v1 += fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2); v78 = 1; break; case PARTY_StrafeRight: - v2 += fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2); - v1 -= fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2); + v2 += fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fWalkSpeedMultiplier / 2); + v1 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fWalkSpeedMultiplier / 2); v78 = 1; break; case PARTY_WalkForward: - v2 += fixpoint_sub0(stru_5C6E00->Cos(angle), 5 * v81 * fWalkSpeedMultiplier); - v1 += fixpoint_sub0(stru_5C6E00->Sin(angle), 5 * v81 * fWalkSpeedMultiplier); + v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 5 * v81 * fWalkSpeedMultiplier); + v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 5 * v81 * fWalkSpeedMultiplier); v78 = 1; break; case PARTY_WalkBackward: - v2 -= fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier); - v1 -= fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier); + v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier); + v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier); v78 = 1; break; case PARTY_RunForward: - v2 += fixpoint_sub0(stru_5C6E00->Cos(angle), 2 * v81 * fWalkSpeedMultiplier); - v1 += fixpoint_sub0(stru_5C6E00->Sin(angle), 2 * v81 * fWalkSpeedMultiplier); + v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * v81 * fWalkSpeedMultiplier); + v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * v81 * fWalkSpeedMultiplier); v72 = 1; break; case PARTY_RunBackward: //v32 = stru_5C6E00->SinCos(angle); //v33 = (double)v81; //v88 = (double)v81; - v2 -= fixpoint_sub0(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier); + v2 -= fixpoint_mul(stru_5C6E00->Cos(angle), v81 * fBackwardWalkSpeedMultiplier); //v34 = stru_5C6E00->SinCos(angle - stru_5C6E00->uIntegerHalfPi); - v1 -= fixpoint_sub0(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier); + v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), v81 * fBackwardWalkSpeedMultiplier); v72 = 1; break; case PARTY_LookUp: @@ -2693,10 +2693,10 @@ } else { - _angle_x = pX + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.x); - _angle_y = pY + fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.y); - pModel = (BSPModel *)fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z); - v40 = fixpoint_sub0(stru_721530.field_7C, stru_721530.direction.z) + pZ; + _angle_x = pX + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); + _angle_y = pY + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); + pModel = (BSPModel *)fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); + v40 = fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z) + pZ; } v122 = v40; ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); @@ -5448,8 +5448,8 @@ v37 += ((unsigned __int64)(pSkyPolygon.ptr_38->field_10 * v13) >> 16); screen_center_x += ((unsigned __int64)(pSkyPolygon.ptr_38->field_1C * v13) >> 16); - v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, pShading) / 8; - screen_center_x = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(screen_center_x, pShading) / 8; + v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, pShading) / 8; + screen_center_x = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(screen_center_x, pShading) / 8; //array_50AC10[i].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; //array_50AC10[i].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0); @@ -6067,7 +6067,7 @@ v15 = grid_x2 - a1; v13 = grid_z1 - a2; } - return v14 + v8 + fixpoint_sub0(v13, (v10 - v8) * 128) + fixpoint_sub0(v15, (v9 - v8) * 128); + return v14 + v8 + fixpoint_mul(v13, (v10 - v8) * 128) + fixpoint_mul(v15, (v9 - v8) * 128); } else return y_x1z1; @@ -6155,10 +6155,10 @@ v24 = pGame->pIndoorCameraD3D->int_cosine_y * -pGame->pIndoorCameraD3D->vPartyPos.y - pGame->pIndoorCameraD3D->int_sine_y * -pGame->pIndoorCameraD3D->vPartyPos.x; if (pGame->pIndoorCameraD3D->sRotationX) { - this->field_0_party_dir_x = fixpoint_sub0(v11, pGame->pIndoorCameraD3D->int_cosine_x) + - fixpoint_sub0((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); + this->field_0_party_dir_x = fixpoint_mul(v11, pGame->pIndoorCameraD3D->int_cosine_x) + + fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, pGame->pIndoorCameraD3D->int_sine_x); this->field_4_party_dir_y = v24; - this->field_8_party_dir_z = fixpoint_sub0((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_sub0(v11, v27); + this->field_8_party_dir_z = fixpoint_mul((-pGame->pIndoorCameraD3D->vPartyPos.z) << 16, v25) - fixpoint_mul(v11, v27); } else { @@ -6169,31 +6169,31 @@ if (pGame->pIndoorCameraD3D->sRotationX) { - v17 = fixpoint_sub0(a2, v9) + fixpoint_sub0(a3, v7); - - this->field_C = fixpoint_sub0(v17, v25) + fixpoint_sub0(a4, v27); - this->field_10 = fixpoint_sub0(a3, v9) - fixpoint_sub0(a2, v7); - this->field_14 = fixpoint_sub0(a4, v25) - fixpoint_sub0(v17, v27); + v17 = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7); + + this->field_C = fixpoint_mul(v17, v25) + fixpoint_mul(a4, v27); + this->field_10 = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7); + this->field_14 = fixpoint_mul(a4, v25) - fixpoint_mul(v17, v27); } else { - this->field_C = fixpoint_sub0(a2, v9) + fixpoint_sub0(a3, v7); - this->field_10 = fixpoint_sub0(a3, v9) - fixpoint_sub0(a2, v7); + this->field_C = fixpoint_mul(a2, v9) + fixpoint_mul(a3, v7); + this->field_10 = fixpoint_mul(a3, v9) - fixpoint_mul(a2, v7); this->field_14 = a4; } if (pGame->pIndoorCameraD3D->sRotationX) { - v19 = fixpoint_sub0(a5, v9) + fixpoint_sub0(a6, v7); - - this->field_18 = fixpoint_sub0(v19, v25) + fixpoint_sub0(a7, v27); - this->field_1C = fixpoint_sub0(a6, v9) - fixpoint_sub0(a5, v7); - this->field_20 = fixpoint_sub0(a7, v25) - fixpoint_sub0(v19, v27); + v19 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7); + + this->field_18 = fixpoint_mul(v19, v25) + fixpoint_mul(a7, v27); + this->field_1C = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7); + this->field_20 = fixpoint_mul(a7, v25) - fixpoint_mul(v19, v27); } else { - this->field_18 = fixpoint_sub0(a5, v9) + fixpoint_sub0(a6, v7); - this->field_1C = fixpoint_sub0(a6, v9) - fixpoint_sub0(a5, v7); + this->field_18 = fixpoint_mul(a5, v9) + fixpoint_mul(a6, v7); + this->field_1C = fixpoint_mul(a6, v9) - fixpoint_mul(a5, v7); this->field_20 = a7; } diff -r 8971dc85b8fb -r 7182930263b3 mm7_4.cpp --- a/mm7_4.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/mm7_4.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -363,7 +363,7 @@ if ( v9 > 0 ) { v10 = v1->vPosition.z; - v11 = stru_721530.normal.z + fixpoint_sub0(stru_721530.direction.z, v9); + v11 = stru_721530.normal.z + fixpoint_mul(stru_721530.direction.z, v9); if ( v11 >= v10 ) { if ( v11 <= v18 + v10 ) diff -r 8971dc85b8fb -r 7182930263b3 mm7_5.cpp --- a/mm7_5.cpp Tue Sep 17 20:15:56 2013 +0200 +++ b/mm7_5.cpp Tue Sep 17 19:24:23 2013 +0100 @@ -4476,9 +4476,9 @@ continue; } - v32 = fixpoint_sub0(v29->pFacePlane_old.vNormal.x,v49); - v33 = fixpoint_sub0(v29->pFacePlane_old.vNormal.z,v47); - v34 = fixpoint_sub0(v29->pFacePlane_old.vNormal.y,v48); + v32 = fixpoint_mul(v29->pFacePlane_old.vNormal.x,v49); + v33 = fixpoint_mul(v29->pFacePlane_old.vNormal.z,v47); + v34 = fixpoint_mul(v29->pFacePlane_old.vNormal.y,v48); v59 = v32 + v33 + v34; if ( v59 ) { @@ -4504,7 +4504,7 @@ if( abs(v38) >> 14 > abs(v59) ) continue; - v58 = fixpoint_sub2(v38,v59); + v58 = fixpoint_div(v38,v59); if( v58 < 0 ) { @@ -4512,9 +4512,9 @@ } if(!sub_4075DB( - obj1_x + ((fixpoint_sub0(v49,v58) + 32768) >> 16), - obj1_y + ((fixpoint_sub0(v48,v58) + 32768) >> 16), - obj1_z + ((fixpoint_sub0(v47,v58) + 32768) >> 16), + obj1_x + ((fixpoint_mul(v49,v58) + 32768) >> 16), + obj1_y + ((fixpoint_mul(v48,v58) + 32768) >> 16), + obj1_z + ((fixpoint_mul(v47,v58) + 32768) >> 16), v29) ) { continue; @@ -4637,8 +4637,8 @@ // + 32768) >> 16) >= a4a) ) else { - v25 = fixpoint_sub2(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]); - if( dword_4F5D98_xs[i] + (fixpoint_sub0(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 32768 >> 16) >= a4a) + v25 = fixpoint_div(dword_4F5D98_xs[i + 1] - dword_4F5D98_xs[i], dword_4F5CC8_ys[i + 1] - dword_4F5CC8_ys[i]); + if( dword_4F5D98_xs[i] + (fixpoint_mul(v25, (v8 - dword_4F5CC8_ys[i]) << 16) + 32768 >> 16) >= a4a) ++a3a; } }