Mercurial > mm7
changeset 2211:b4bb8296ecfa
Слияние
author | Ritor1 |
---|---|
date | Wed, 12 Feb 2014 20:51:37 +0600 |
parents | 7d5c05264a0d (current diff) 3664342f5d93 (diff) |
children | e18200fcfb50 |
files | |
diffstat | 15 files changed, 527 insertions(+), 639 deletions(-) [+] |
line wrap: on
line diff
--- a/Arcomage.cpp Wed Feb 12 20:51:31 2014 +0600 +++ b/Arcomage.cpp Wed Feb 12 20:51:37 2014 +0600 @@ -2693,135 +2693,94 @@ //----- (0040BB67) -------------------------------------------------------- signed int DrawCardsRectangles( int player_num ) { -//int v1; // esi@1 signed int result; // eax@1 -int v3; // ebx@1 -char v4; // zf@1 int v5; // eax@3 -int v6; // eax@4 int v7; // ecx@6 -char *v8; // eax@6 -int v9; // eax@10 int v10; // ecx@10 int v11; // eax@10 -char v12; // ch@2@11 -int v13; // ST00_4@12 -unsigned __int16 v14; // ax@12 -int v15; // eax@13 int v16; // ecx@13 int v17; // eax@13 -char v18; // al@16 -char v19; // ch@2@16 int v20; // ST00_4@19 -unsigned __int16 v21; // ax@19 RECT pXYZW; // [sp+Ch] [bp-3Ch]@3 stru273 v26; // [sp+1Ch] [bp-2Ch]@2 -int v25; // [sp+2Ch] [bp-1Ch]@3 __int32 var18; // [sp+30h] [bp-18h]@3 -int i; // [sp+34h] [bp-14h]@4 int v28; // [sp+38h] [bp-10h]@1 int hand_index; // [sp+3Ch] [bp-Ch]@3 -int v30; // [sp+40h] [bp-8h]@1 -char v31; // [sp+44h] [bp-4h]@12 -char v32; // [sp+45h] [bp-3h]@12 -char v33; // [sp+46h] [bp-2h]@12 - -__debugbreak(); // need do fix rectangle not fit to card - -v30 = 0; -result = -1; -//v3 = 188 * a1; - -//v4 = LOBYTE(am_Players[a1].field_20) == 0; -v28 = -1; -if ( am_Players[player_num].IsHisTurn ) + +//__debugbreak(); // need do fix rectangle not fit to card + + //v30 = 0; + result = -1; + //v3 = 188 * a1; + + //v4 = LOBYTE(am_Players[a1].field_20) == 0; + v28 = -1; + if ( am_Players[player_num].IsHisTurn ) + { + if ( v26._40DD2F() ) { - if ( v26._40DD2F() ) + v5 = GetPlayerHandCardCount(player_num); + pXYZW.top = 327; + pXYZW.bottom = 455; + pXYZW.left = (640 - 96 * v5) / (v5 + 1); + var18 = pXYZW.left + 96; + pXYZW.right = pXYZW.left + 96; + if ( v5 > 0 ) + { + // v6 = 47 * v1; + // for ( i = player_num; ; v6 = i ) + for( hand_index = 0; hand_index < v5; hand_index++) { - v5 = GetPlayerHandCardCount(player_num); - hand_index = 0; - v25 = v5; - pXYZW.top = 327; - pXYZW.bottom = 455; - pXYZW.left = (640 - 96 * v5) / (v5 + 1); - var18 = pXYZW.left + 96; - pXYZW.right = pXYZW.left + 96; - if ( v5 > 0 ) - { - // v6 = 47 * v1; - // for ( i = player_num; ; v6 = i ) - for(;;) - { - v7 = v30; - // v8 = &am_Players[0].cards_at_hand[v30 + v6]; - - for (v7=0; v7<10; ++v7) - { - if (am_Players[player_num].cards_at_hand[v7]!= -1 ) - break; - } - //if ( *v8 ) - // { - // do - // { - // //v8 += 4; - // ++v7; - // } - // while ( *v8 == -1 ); - v30 = v7; - // } - if ( am_byte_4E185D ) - { - // v9 = v3 + 8 * v7; - v10 = am_Players[player_num].card_shift[v7].x;//*(am_player[0].arr_6C[0] + v9); - v11 = am_Players[player_num].card_shift[v7].y;//*(&am_player[0].arr_6C[0][1] + v9); - pXYZW.left += v10; - pXYZW.right += v10; - pXYZW.top += v11; - pXYZW.bottom += v11; - } - if (v26.Inside(&pXYZW) ) - break; - - v13=0; - v14 = R8G8B8_to_TargetFormat(v13); - DrawRect(&pXYZW, v14, 0); - pXYZW.left += var18; - pXYZW.right += var18; - if ( am_byte_4E185D ) - { - v16 = am_Players[player_num].card_shift[v30].x;//*(am_player[0].arr_6C[0] + v15); - v17 = am_Players[player_num].card_shift[v30].y;//*(&am_player[0].arr_6C[0][1] + v15); - pXYZW.left -= v16; - pXYZW.right -= v16; - pXYZW.top -= v17; - pXYZW.bottom -= v17; - } - ++v30; - ++hand_index; - if ( hand_index >= v25 ) - return v28; - } - v28 = hand_index; - v18 = CanCardBePlayed(player_num, hand_index); - if ( v18 ) - { - v20=0x00FFFFFF; - } + // v8 = &am_Players[0].cards_at_hand[v30 + v6]; + for ( v7 = 0; v7 < 10; ++v7 ) + { + if (am_Players[player_num].cards_at_hand[v7]!= -1 ) + break; + } + //if ( *v8 ) + // { + // do + // { + // //v8 += 4; + // ++v7; + // } + // while ( *v8 == -1 ); + //v30 = v7; + // } + if ( am_byte_4E185D ) + { + pXYZW.left += am_Players[player_num].card_shift[v7].x; + pXYZW.right += am_Players[player_num].card_shift[v7].x; + pXYZW.top += am_Players[player_num].card_shift[v7].y; + pXYZW.bottom += am_Players[player_num].card_shift[v7].y; + } + if (v26.Inside(&pXYZW) ) + { + if ( CanCardBePlayed(player_num, hand_index) ) + v20 = 0x00FFFFFF;// else - { - v20=0x000000FF; - } - - v21 = R8G8B8_to_TargetFormat(v20); - DrawRect(&pXYZW, v21, 0); - } + v20 = 0x000000FF;// + DrawRect(&pXYZW, R8G8B8_to_TargetFormat(v20), 0); + return hand_index; + } + DrawRect(&pXYZW, R8G8B8_to_TargetFormat(0), 0);// + pXYZW.left += var18; + pXYZW.right += var18; + if ( am_byte_4E185D ) + { + v16 = am_Players[player_num].card_shift[v7].x;//*(am_player[0].arr_6C[0] + v15); + v17 = am_Players[player_num].card_shift[v7].y;//*(&am_player[0].arr_6C[0][1] + v15); + pXYZW.left -= v16; + pXYZW.right -= v16; + pXYZW.top -= v17; + pXYZW.bottom -= v17; + } } - result = v28; + } } -return result; - - + result = v28; + } + return result; } // 4E185D: using guessed type char am_byte_4E185D;
--- a/Indoor.cpp Wed Feb 12 20:51:31 2014 +0600 +++ b/Indoor.cpp Wed Feb 12 20:51:37 2014 +0600 @@ -3472,13 +3472,9 @@ if ( v55 >= 50 ) break; if ( pFloor->uPolygonType == POLYGON_Floor || pFloor->uPolygonType == POLYGON_Ceiling ) - { v21 = pIndoor->pVertices[pFloor->pVertexIDs[0]].z; - } else - { 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]; v55++; @@ -3486,7 +3482,6 @@ } } - if ( pSector->field_0 & 8 ) { for (uint i = 0; i < pSector->uNumPortals; ++i) @@ -3551,6 +3546,8 @@ if ( v55 == 1 ) { *pFaceID = blv_floor_id[0]; + if ( blv_floor_level[0] <= -29000 ) + __debugbreak(); return blv_floor_level[0]; } if ( !v55 ) @@ -3585,12 +3582,16 @@ if ( v38 > result && v38 <= z + 5 ) { result = blv_floor_level[i]; + if ( blv_floor_level[i] <= -29000 ) + __debugbreak(); *pFaceID = blv_floor_id[i]; } } else if ( v38 < result ) { result = blv_floor_level[i]; + if ( blv_floor_level[i] <= -29000 ) + __debugbreak(); *pFaceID = blv_floor_id[i]; } } @@ -5981,7 +5982,7 @@ int v80; // [sp+34h] [bp-2Ch]@1 int v82; // [sp+3Ch] [bp-24h]@47 int _view_angle; // [sp+40h] [bp-20h]@47 - bool bJumping; // [sp+44h] [bp-1Ch]@1 + bool hovering; // [sp+44h] [bp-1Ch]@1 int new_party_y; // [sp+48h] [bp-18h]@1 int new_party_x; // [sp+4Ch] [bp-14h]@1 int party_z; // [sp+50h] [bp-10h]@1 @@ -5997,12 +5998,12 @@ uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); party_running_flag = false; party_walking_flag = false; - bJumping = false; + hovering = false; uFaceID = -1; - int floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID); - - if ( pParty->bFlying ) + int floor_level = collide_against_floor(new_party_x, new_party_y, party_z + 40, &uSectorID, &uFaceID);// + + if ( pParty->bFlying )// { pParty->bFlying = false; if (pParty->FlyActive()) @@ -6043,8 +6044,8 @@ } } - uint fall_start; - if (!pParty->FeatherFallActive()) + int fall_start; + if (!pParty->FeatherFallActive())// { bFeatherFall = false; if (!pParty->pPlayers[0].WearsItemAnyWhere(ITEM_ARTIFACT_LADYS_ESCORT) && // grants feather fall @@ -6055,7 +6056,7 @@ fall_start = pParty->uFallStartY; } } - else + else// { fall_start = floor_level; bFeatherFall = true; @@ -6063,7 +6064,7 @@ } - if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1) + if (fall_start - party_z > 512 && !bFeatherFall && party_z <= floor_level + 1)// { assert(~pParty->uFlags & PARTY_FLAGS_1_LANDING); // why land in indoor? if (pParty->uFlags & PARTY_FLAGS_1_LANDING) @@ -6080,40 +6081,39 @@ } if ( party_z > floor_level + 1 ) - bJumping = true; - - bool jumping_up = false; + hovering = true; + + bool not_high_fall = false; if ( party_z - floor_level <= 32 ) { pParty->uFallStartY = party_z; - jumping_up = true; + not_high_fall = true; } - if (bWalkSound && pParty->walk_sound_timer) + if (bWalkSound && pParty->walk_sound_timer)// { if (pParty->walk_sound_timer > pEventTimer->uTimeElapsed) pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; else pParty->walk_sound_timer = 0; } - - if (party_z <= floor_level + 1) + if (party_z <= floor_level + 1)// { party_z = floor_level + 1; pParty->uFallStartY = floor_level + 1; - if (!bJumping && pParty->floor_face_pid != uFaceID) + if (!hovering && pParty->floor_face_pid != uFaceID)// { if (pIndoor->pFaces[uFaceID].uAttributes & FACE_PRESSURE_PLATE) uFaceEvent = pIndoor->pFaceExtras[pIndoor->pFaces[uFaceID].uFaceExtraID].uEventID; } } - if (!bJumping) + if (!hovering) pParty->floor_face_pid = uFaceID; bool on_water = false; - if ( pIndoor->pFaces[uFaceID].Fluid()) + if ( pIndoor->pFaces[uFaceID].Fluid())// on_water = true; //v81 = pParty->uWalkSpeed; @@ -6172,7 +6172,7 @@ v1 -= fixpoint_mul(stru_5C6E00->Sin(angle), pParty->uWalkSpeed * fBackwardWalkSpeedMultiplier); party_walking_flag = true; break; - case PARTY_RunForward: + case PARTY_RunForward:// v2 += fixpoint_mul(stru_5C6E00->Cos(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier); v1 += fixpoint_mul(stru_5C6E00->Sin(angle), 2 * pParty->uWalkSpeed * fWalkSpeedMultiplier); party_running_flag = true; @@ -6204,9 +6204,9 @@ _view_angle = 0; break; case PARTY_Jump: - if ( (!bJumping || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 ) + if ( (!hovering || party_z <= floor_level + 6 && pParty->uFallSpeed <= 0) && pParty->field_24 ) { - bJumping = true; + hovering = true; pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed); } break; @@ -6216,17 +6216,16 @@ } pParty->sRotationY = angle; pParty->sRotationX = _view_angle; - if ( bJumping ) + if ( hovering )// { - pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); - if ( bJumping && pParty->uFallSpeed <= 0 ) + pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength();// + if ( hovering && pParty->uFallSpeed <= 0 ) { if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) { for ( uint pl = 1; pl <= 4; pl++ ) { - if ( !pPlayers[pl]->HasEnchantedItemEquipped(72) - && !pPlayers[pl]->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 + if ( !pPlayers[pl]->HasEnchantedItemEquipped(72) && !pPlayers[pl]->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); } } @@ -6234,9 +6233,9 @@ else pParty->uFallStartY = party_z; } - else + else// { - if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) + if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 0x8000 ) { pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); pParty->uFallStartY = party_z; @@ -6284,10 +6283,10 @@ for ( uint j = 0; j < 100; ++j ) { _46E44E_collide_against_faces_and_portals(1); - _46E0B2_collide_against_decorations(); + _46E0B2_collide_against_decorations();// for ( v80 = 0; v80 < (signed int)uNumActors; ++v80 ) - Actor::_46DF1A_collide_against_actor(v80, 0); - if ( _46F04E_collide_against_portals() ) + Actor::_46DF1A_collide_against_actor(v80, 0);// + if ( _46F04E_collide_against_portals() )// break; } if ( stru_721530.field_7C >= stru_721530.field_6C ) @@ -6305,7 +6304,7 @@ v42 = collide_against_floor(v39, uSectorID, v40 + 40, &stru_721530.uSectorID, &uFaceID); if ( v42 == -30000 || v42 - new_party_z > 128 ) return; - if ( stru_721530.field_7C >= stru_721530.field_6C ) + if ( stru_721530.field_7C >= stru_721530.field_6C )//??? { new_party_x = stru_721530.normal2.x; new_party_y = stru_721530.normal2.y; @@ -6317,24 +6316,23 @@ uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; unsigned long long v87 = new_party_z + fixpoint_mul(stru_721530.field_7C, stru_721530.direction.z); - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor)// { - if ( SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) >= 0 - && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = true; } - else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) + else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration)// { v54 = stru_5C6E00->Atan2(new_party_x - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.x, new_party_y - pLevelDecorations[stru_721530.uFaceID >> 3].vPosition.y); v2 = fixpoint_mul(stru_5C6E00->Cos(v54), integer_sqrt(v2 * v2 + v1 * v1)); v1 = fixpoint_mul(stru_5C6E00->Sin(v54), integer_sqrt(v2 * v2 + v1 * v1)); } - else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) + else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel)// bmodel { pFace = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; - if ( pFace->uPolygonType == POLYGON_Floor ) + if ( pFace->uPolygonType == POLYGON_Floor )// bmodel - { if ( pParty->uFallSpeed < 0 ) pParty->uFallSpeed = 0; @@ -6349,10 +6347,10 @@ if ( pParty->floor_face_pid != PID_ID(stru_721530.uFaceID) && pFace->Pressure_Plate() ) uFaceEvent = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; } - else + else// { v46 = pParty->uFallSpeed * pFace->pFacePlane_old.vNormal.z; - if ( pFace->uPolygonType != POLYGON_InBetweenFloorAndWall ) + if ( pFace->uPolygonType != POLYGON_InBetweenFloorAndWall )// { v80 = abs(v1 * pFace->pFacePlane_old.vNormal.y + v46 + v2 * pFace->pFacePlane_old.vNormal.x) >> 16; if ((stru_721530.speed >> 3) > v80 ) @@ -6402,13 +6400,13 @@ } // // /------------------------- - uint pX_ = pParty->vPosition.x - new_party_x; - uint pY_ = pParty->vPosition.y - new_party_y; - uint pZ_ = pParty->vPosition.z - new_party_z; + uint pX_ = abs(pParty->vPosition.x - new_party_x); + uint pY_ = abs(pParty->vPosition.y - new_party_y); + uint pZ_ = abs(pParty->vPosition.z - new_party_z); if ( bWalkSound && pParty->walk_sound_timer <= 0 ) { pAudioPlayer->_4AA258(804);//stop sound - if ( party_running_flag && (!bJumping || jumping_up) ) // + if ( party_running_flag && (!hovering || not_high_fall) ) // ( ) { if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 16 ) { @@ -6418,10 +6416,10 @@ pAudioPlayer->PlaySound((SoundID)50, 804, 1, -1, 0, 0, 0, 0); else pAudioPlayer->PlaySound(SOUND_RunAlong3DModel, 804, 1, -1, 0, 0, 0, 0); - pParty->walk_sound_timer = 64; + pParty->walk_sound_timer = 96;//64 } } - else if ( party_walking_flag && (!bJumping || jumping_up) )// + else if ( party_walking_flag && (!hovering || not_high_fall) )// ( ) { if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 8 ) { @@ -6431,14 +6429,14 @@ pAudioPlayer->PlaySound((SoundID)89, 804, 1, -1, 0, 0, 0, 0); else pAudioPlayer->PlaySound(SOUND_WalkAlong3DModel, 804, 1, -1, 0, 0, 0, 0); - pParty->walk_sound_timer = 64; + pParty->walk_sound_timer = 144;//64 } } } if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) < 8 )// pAudioPlayer->_4AA258(804); //------------------------------------------------------------- - if ( !bJumping || jumping_up ) + if ( !hovering || !not_high_fall ) pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; else pParty->uFlags |= PARTY_FLAGS_1_FALLING; @@ -6447,7 +6445,7 @@ pParty->vPosition.z = new_party_z; pParty->vPosition.y = new_party_y; //pParty->uFallSpeed = v89; - if ( !bJumping && pIndoor->pFaces[uFaceID].uAttributes & FACE_UNKNOW5 ) + if ( !hovering && pIndoor->pFaces[uFaceID].uAttributes & FACE_UNKNOW5 ) pParty->uFlags |= 0x200; if (uFaceEvent) EventProcessor(uFaceEvent, 0, 1);
--- a/IndoorCameraD3D.cpp Wed Feb 12 20:51:31 2014 +0600 +++ b/IndoorCameraD3D.cpp Wed Feb 12 20:51:37 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 Wed Feb 12 20:51:31 2014 +0600 +++ b/LOD.cpp Wed Feb 12 20:51:37 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; } @@ -1383,72 +1383,70 @@ //----- (00461FD4) ---LODFile_sub_461FD4---text:004632EA -------------------------------------------------- int LODWriteableFile::FixDirectoryOffsets() { - int total_size; // edi@1 - int temp_offset; // ecx@5 - FILE *tmp_file; // eax@9 - size_t write_size; // edi@12 - int result; - char Filename[256]; // [sp+Ch] [bp-228h]@9 - char NewFilename[256]; // [sp+10Ch] [bp-128h]@15 - int i; + int total_size; // edi@1 + int temp_offset; // ecx@5 + FILE *tmp_file; // eax@9 + size_t write_size; // edi@12 + int result; + char Filename[256]; // [sp+Ch] [bp-228h]@9 + char NewFilename[256]; // [sp+10Ch] [bp-128h]@15 + int i; - total_size = 0; - for (i=0;i<uNumSubDirs;i++) - total_size+=pSubIndices[i].uDataSize; - //fix offsets - temp_offset = sizeof(LOD::Directory) * uNumSubDirs; - for (i=0;i<uNumSubDirs;i++) - { - pSubIndices[i].uOfsetFromSubindicesStart=temp_offset; - temp_offset+=pSubIndices[i].uDataSize; - } - strcpy(Filename, "lod.tmp"); - tmp_file = fopen(Filename, "wb+"); + total_size = 0; + for ( i = 0; i < uNumSubDirs; i++ ) + total_size += pSubIndices[i].uDataSize; + //fix offsets + temp_offset = sizeof(LOD::Directory) * uNumSubDirs; + for ( i = 0; i < uNumSubDirs; i++ ) + { + pSubIndices[i].uOfsetFromSubindicesStart=temp_offset; + temp_offset+=pSubIndices[i].uDataSize; + } + strcpy(Filename, "lod.tmp"); + tmp_file = fopen(Filename, "wb+"); - if ( tmp_file ) - { - fwrite((const void *)&header, sizeof(LOD::FileHeader), 1, tmp_file); + if ( tmp_file ) + { + fwrite((const void *)&header, sizeof(LOD::FileHeader), 1, tmp_file); - LOD::Directory Lindx; - strcpy(Lindx.pFilename, "chapter"); - Lindx.uOfsetFromSubindicesStart=uOffsetToSubIndex; //10h 16 - Lindx.uDataSize=sizeof(LOD::Directory) * uNumSubDirs + total_size; //14h 20 - Lindx.dword_000018=0; //18h 24 - Lindx.uNumSubIndices=uNumSubDirs; //1ch 28 - Lindx.word_00001E=0; // 1Eh 30 - fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file); - fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file); - fseek(pOutputFileHandle, 0, 0); - if ( total_size > 0 ) - { - do - { - write_size = uIOBufferSize; - if ( total_size <= (signed int)uIOBufferSize ) - write_size =total_size; - fread(pIOBuffer, 1, write_size, pOutputFileHandle); - fwrite(pIOBuffer, 1, write_size, tmp_file); - total_size -= write_size; - } - while ( total_size > 0 ); - } - strcpy(NewFilename, (const char *)&pLODName); - fclose(tmp_file); - fclose(pOutputFileHandle); - CloseWriteFile(); - remove("lodapp.tmp"); - remove(NewFilename); - rename(Filename, NewFilename); - CloseWriteFile(); - LoadFile( (const char *)&pLODName, 0); - result = 0; - } - else - { - result = 5; - } - return result; + LOD::Directory Lindx; + strcpy(Lindx.pFilename, "chapter"); + Lindx.uOfsetFromSubindicesStart = uOffsetToSubIndex; //10h 16 + Lindx.uDataSize = sizeof(LOD::Directory) * uNumSubDirs + total_size; //14h 20 + Lindx.dword_000018 = 0; //18h 24 + Lindx.uNumSubIndices = uNumSubDirs; //1ch 28 + Lindx.word_00001E = 0; // 1Eh 30 + fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file); + fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file); + fseek(pOutputFileHandle, 0, 0); + if ( total_size > 0 ) + { + do + { + write_size = uIOBufferSize; + if ( total_size <= (signed int)uIOBufferSize ) + write_size =total_size; + fread(pIOBuffer, 1, write_size, pOutputFileHandle); + fwrite(pIOBuffer, 1, write_size, tmp_file); + total_size -= write_size; + } + while ( total_size > 0 ); } + strcpy(NewFilename, (const char *)&pLODName); + fclose(tmp_file); + fclose(pOutputFileHandle); + CloseWriteFile(); + remove("lodapp.tmp"); + remove(NewFilename); + rename(Filename, NewFilename); + CloseWriteFile(); + LoadFile( (const char *)&pLODName, 0); + result = 0; + } + else + result = 5; + return result; +} //----- (00461F71) -------------------------------------------------------- bool LOD::File::AppendDirectory(LOD::Directory *pDir, const void *pData) @@ -1491,6 +1489,8 @@ fclose(pFile); pFile = 0; } + //else + //__debugbreak(); } // 6A0CA8: using guessed type int 6A0CA8_lod_unused; @@ -1641,25 +1641,18 @@ to_copy_size -= read_size; } //replace old file by new with added data - strcpy(NewFilename, pLODName); + strcpy(NewFilename, (const char *)&pLODName); fclose(tmp_file); - bool test_file_opened1 = isFileOpened; - CloseWriteFile(); //isFileOpened == false, current file - bool test_file_opened2 = isFileOpened; + fclose(pFile); + CloseWriteFile(); remove(NewFilename); - bool test_file_opened3 = isFileOpened; rename(Filename, NewFilename); - bool test_file_opened4 = isFileOpened; CloseWriteFile(); - bool test_file_opened5 = isFileOpened; //reload new - LoadFile(pLODName, 0);//isFileOpened == true, next file - if (isFileOpened == false) - __debugbreak(); + LoadFile((const char *)&pLODName, 0);//isFileOpened == true, next file return 0; } - //----- (00461A43) -------------------------------------------------------- bool LODWriteableFile::LoadFile(const char *pFilename, bool bWriting) {
--- a/Outdoor.cpp Wed Feb 12 20:51:31 2014 +0600 +++ b/Outdoor.cpp Wed Feb 12 20:51:37 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; } @@ -3405,7 +3406,7 @@ int v96; // [sp-4h] [bp-98h]@246 int v97; // [sp+Ch] [bp-88h]@180 Vec3_int_ v98; - bool high_fall_flag; // [sp+1Ch] [bp-78h]@33 + bool not_high_fall; // [sp+1Ch] [bp-78h]@33 int v102; // [sp+20h] [bp-74h]@1 int trigger_id; // [sp+24h] [bp-70h]@1 bool bFeatherFall; // [sp+28h] [bp-6Ch]@4 @@ -3487,9 +3488,7 @@ if ( floor_level - pZ > 512 && !bFeatherFall && pZ <= v111 + 1 )// 3D Model { if (pParty->uFlags & PARTY_FLAGS_1_LANDING) - { pParty->uFlags &= ~PARTY_FLAGS_1_LANDING; - } else for (int i = 0; i < 4; ++i) // receive falling damage { if ( !pParty->pPlayers[i].HasEnchantedItemEquipped(72) && !pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) @@ -3514,7 +3513,7 @@ } else hovering = true; - high_fall_flag = pZ - v111 <= 32; + not_high_fall = pZ - v111 <= 32; if ( bWalkSound && pParty->walk_sound_timer)//timer update { @@ -4154,15 +4153,15 @@ } // /------------------------ - v122 = abs(pParty->vPosition.x - pX); + uint pX_ = abs(pParty->vPosition.x - pX); uint pY_ = abs(pParty->vPosition.y - pY); - v62 = abs(pParty->vPosition.z - pZ); + uint pZ_ = abs(pParty->vPosition.z - pZ); if ( bWalkSound && pParty->walk_sound_timer <= 0 ) { pAudioPlayer->_4AA258(804);//stop sound - if ( party_running_flag && (!hovering || high_fall_flag) ) + if ( party_running_flag && (!hovering || not_high_fall) ) { - if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 16 ) + if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 16 ) { if ( !is_not_on_bmodel && pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].Visible() ) pAudioPlayer->PlaySound(SOUND_RunAlong3DModel, 804, 1, -1, 0, 0, 0, 0);// 3D Model @@ -4174,9 +4173,9 @@ pParty->walk_sound_timer = 96;// } } - else if( party_walking_flag && (!hovering || high_fall_flag) ) + else if( party_walking_flag && (!hovering || not_high_fall) ) { - if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) >= 8 ) + if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) >= 8 ) { if ( !is_not_on_bmodel && pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].Visible() ) pAudioPlayer->PlaySound(SOUND_WalkAlong3DModel, 804, 1, -1, 0, 0, 0, 0);// 3D Model @@ -4189,10 +4188,10 @@ } } } - if ( integer_sqrt(v122 * v122 + pY_ * pY_ + v62 * v62) < 8 )// + if ( integer_sqrt(pX_ * pX_ + pY_ * pY_ + pZ_ * pZ_) < 8 )// pAudioPlayer->_4AA258(804); //------------------------------------------------------------------------ - if ( !hovering || !high_fall_flag ) + if ( !hovering || !not_high_fall )// pParty->uFlags &= ~PARTY_FLAGS_1_FALLING; else pParty->uFlags |= PARTY_FLAGS_1_FALLING; @@ -4267,12 +4266,12 @@ } //----------------------------------------------------------------- //v76 = pParty->bFlying; - if ( pParty->bFlying || !high_fall_flag || bWaterWalk || !v122_a ) + if ( pParty->bFlying || !not_high_fall || bWaterWalk || !v122_a )// v77 = 1; else v77 = v122 != 0; bool party_drowning_flag = false; - if ( !pParty->bFlying && high_fall_flag && !bWaterWalk ) // , , + if ( !pParty->bFlying && not_high_fall && !bWaterWalk ) // { if ( v122_a ) v78 = v69 != 0; @@ -4451,8 +4450,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 Wed Feb 12 20:51:31 2014 +0600 +++ b/ParticleEngine.cpp Wed Feb 12 20:51:37 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 Wed Feb 12 20:51:31 2014 +0600 +++ b/Render.cpp Wed Feb 12 20:51:37 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 (010000) 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 Wed Feb 12 20:51:31 2014 +0600 +++ b/SpriteObject.cpp Wed Feb 12 20:51:37 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 Wed Feb 12 20:51:31 2014 +0600 +++ b/Sprites.cpp Wed Feb 12 20:51:37 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/VideoPlayer.h Wed Feb 12 20:51:31 2014 +0600 +++ b/VideoPlayer.h Wed Feb 12 20:51:37 2014 +0600 @@ -266,13 +266,20 @@ int num_processed_buffers; alGetSourcei(samples_source_id, AL_BUFFERS_PROCESSED, &num_processed_buffers); - while (num_processed_buffers) + /*while (num_processed_buffers) { unsigned int processed_buffers_id[4]; alSourceUnqueueBuffers(samples_source_id, min(4, num_processed_buffers), processed_buffers_id); CheckError(); alGetSourcei(samples_source_id, AL_BUFFERS_PROCESSED, &num_processed_buffers); - } + }*/ + for (int i = 0; i < num_processed_buffers; ++i) + { + unsigned int processed_buffer_id; + alSourceUnqueueBuffers(samples_source_id, 1, &processed_buffer_id); + if (!CheckError()) + alDeleteBuffers(1, &processed_buffer_id); + } int num_queued_buffers; alGetSourcei(samples_source_id, AL_BUFFERS_QUEUED, &num_queued_buffers);
--- a/Viewport.cpp Wed Feb 12 20:51:31 2014 +0600 +++ b/Viewport.cpp Wed Feb 12 20:51:37 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 Wed Feb 12 20:51:31 2014 +0600 +++ b/mm7_2.cpp Wed Feb 12 20:51:37 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; } @@ -2267,8 +2225,6 @@ return result; } - - //----- (00452B2E) -------------------------------------------------------- int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) {
--- a/mm7_3.cpp Wed Feb 12 20:51:31 2014 +0600 +++ b/mm7_3.cpp Wed Feb 12 20:51:37 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 Wed Feb 12 20:51:31 2014 +0600 +++ b/mm7_5.cpp Wed Feb 12 20:51:37 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 Wed Feb 12 20:51:31 2014 +0600 +++ b/stru6.cpp Wed Feb 12 20:51:37 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,