diff --git a/src_rebuild/DebugOverlay.cpp b/src_rebuild/DebugOverlay.cpp index a3534d30..7218a31c 100644 --- a/src_rebuild/DebugOverlay.cpp +++ b/src_rebuild/DebugOverlay.cpp @@ -199,9 +199,9 @@ void DoFreeCamera() BuildFreeCameraMatrix(); - g_FreeCameraPosition.vx += FIXED(g_FreeCameraVelocity.vx); - g_FreeCameraPosition.vy += FIXED(g_FreeCameraVelocity.vy); - g_FreeCameraPosition.vz += FIXED(g_FreeCameraVelocity.vz); + g_FreeCameraPosition.vx += FIXEDH(g_FreeCameraVelocity.vx); + g_FreeCameraPosition.vy += FIXEDH(g_FreeCameraVelocity.vy); + g_FreeCameraPosition.vz += FIXEDH(g_FreeCameraVelocity.vz); // deaccel g_FreeCameraVelocity.vx -= (g_FreeCameraVelocity.vx / 8); diff --git a/src_rebuild/EMULATOR/LIBGTE.C b/src_rebuild/EMULATOR/LIBGTE.C index 898d0e88..92a71f27 100644 --- a/src_rebuild/EMULATOR/LIBGTE.C +++ b/src_rebuild/EMULATOR/LIBGTE.C @@ -14,7 +14,7 @@ #include "GTE/sqrt_tbl.h" #define ONE 4096 -#define FIXED(a) ((a) / ONE) +#define FIXEDH(a) ((a) / ONE) GTERegisters gteRegs; @@ -1239,21 +1239,21 @@ MATRIX* MulMatrix0(MATRIX* m0, MATRIX* m1, MATRIX* m2) vx = m1->m[0][0]; vy = m1->m[1][0]; vz = m1->m[2][0]; - m2->m[0][0] = FIXED(m0->m[0][0] * vx + m0->m[0][1] * vy + m0->m[0][2] * vz); - m2->m[1][0] = FIXED(m0->m[1][0] * vx + m0->m[1][1] * vy + m0->m[1][2] * vz); - m2->m[2][0] = FIXED(m0->m[2][0] * vx + m0->m[2][1] * vy + m0->m[2][2] * vz); + m2->m[0][0] = FIXEDH(m0->m[0][0] * vx + m0->m[0][1] * vy + m0->m[0][2] * vz); + m2->m[1][0] = FIXEDH(m0->m[1][0] * vx + m0->m[1][1] * vy + m0->m[1][2] * vz); + m2->m[2][0] = FIXEDH(m0->m[2][0] * vx + m0->m[2][1] * vy + m0->m[2][2] * vz); vx = m1->m[0][1]; vy = m1->m[1][1]; vz = m1->m[2][1]; - m2->m[0][1] = FIXED(m0->m[0][0] * vx + m0->m[0][1] * vy + m0->m[0][2] * vz); - m2->m[1][1] = FIXED(m0->m[1][0] * vx + m0->m[1][1] * vy + m0->m[1][2] * vz); - m2->m[2][1] = FIXED(m0->m[2][0] * vx + m0->m[2][1] * vy + m0->m[2][2] * vz); + m2->m[0][1] = FIXEDH(m0->m[0][0] * vx + m0->m[0][1] * vy + m0->m[0][2] * vz); + m2->m[1][1] = FIXEDH(m0->m[1][0] * vx + m0->m[1][1] * vy + m0->m[1][2] * vz); + m2->m[2][1] = FIXEDH(m0->m[2][0] * vx + m0->m[2][1] * vy + m0->m[2][2] * vz); vx = m1->m[0][2]; vy = m1->m[1][2]; vz = m1->m[2][2]; - m2->m[0][2] = FIXED(m0->m[0][0] * vx + m0->m[0][1] * vy + m0->m[0][2] * vz); - m2->m[1][2] = FIXED(m0->m[1][0] * vx + m0->m[1][1] * vy + m0->m[1][2] * vz); - m2->m[2][2] = FIXED(m0->m[2][0] * vx + m0->m[2][1] * vy + m0->m[2][2] * vz); + m2->m[0][2] = FIXEDH(m0->m[0][0] * vx + m0->m[0][1] * vy + m0->m[0][2] * vz); + m2->m[1][2] = FIXEDH(m0->m[1][0] * vx + m0->m[1][1] * vy + m0->m[1][2] * vz); + m2->m[2][2] = FIXEDH(m0->m[2][0] * vx + m0->m[2][1] * vy + m0->m[2][2] * vz); #endif return m2; @@ -1303,9 +1303,9 @@ void SetFarColor(long rfc, long gfc, long bfc) int vx = v0->vx;\ int vy = v0->vy;\ int vz = v0->vz;\ - v1->vx = FIXED(m->m[0][0]*vx + m->m[0][1]*vy + m->m[0][2]*vz );\ - v1->vy = FIXED(m->m[1][0]*vx + m->m[1][1]*vy + m->m[1][2]*vz );\ - v1->vz = FIXED(m->m[2][0]*vx + m->m[2][1]*vy + m->m[2][2]*vz );\ + v1->vx = FIXEDH(m->m[0][0]*vx + m->m[0][1]*vy + m->m[0][2]*vz );\ + v1->vy = FIXEDH(m->m[1][0]*vx + m->m[1][1]*vy + m->m[1][2]*vz );\ + v1->vz = FIXEDH(m->m[2][0]*vx + m->m[2][1]*vy + m->m[2][2]*vz );\ } VECTOR* ApplyMatrix(MATRIX* m, SVECTOR* v0, VECTOR* v1) @@ -1370,15 +1370,15 @@ MATRIX* RotMatrix(struct SVECTOR* r, MATRIX* m) s2s0 = (c2m0 - c2p0) / 2; c2c0 = (c2m0 + c2p0) / 2; - m->m[0][0] = FIXED(c2 * c1); - m->m[1][0] = s2c0 + FIXED(c2s0 * s1); - m->m[2][0] = s2s0 - FIXED(c2c0 * s1); - m->m[0][1] = -FIXED(s2 * c1); - m->m[1][1] = c2c0 - FIXED(s2s0 * s1); - m->m[2][1] = c2s0 + FIXED(s2c0 * s1); + m->m[0][0] = FIXEDH(c2 * c1); + m->m[1][0] = s2c0 + FIXEDH(c2s0 * s1); + m->m[2][0] = s2s0 - FIXEDH(c2c0 * s1); + m->m[0][1] = -FIXEDH(s2 * c1); + m->m[1][1] = c2c0 - FIXEDH(s2s0 * s1); + m->m[2][1] = c2s0 + FIXEDH(s2c0 * s1); m->m[0][2] = s1; - m->m[1][2] = -FIXED(c1 * s0); - m->m[2][2] = FIXED(c1 * c0); + m->m[1][2] = -FIXEDH(c1 * s0); + m->m[2][2] = FIXEDH(c1 * c0); return m; } @@ -1427,8 +1427,8 @@ MATRIX* RotMatrixYXZ(struct SVECTOR* r, MATRIX* m) uVar4 = (r->vz); m->m[1][2] = sVar3; - m->m[0][2] = FIXED(iVar1 * iVar6); - sVar3 = FIXED(iVar7 * iVar6); + m->m[0][2] = FIXEDH(iVar1 * iVar6); + sVar3 = FIXEDH(iVar7 * iVar6); if ((int)uVar4 < 0) { @@ -1445,14 +1445,14 @@ MATRIX* RotMatrixYXZ(struct SVECTOR* r, MATRIX* m) iVar8 = iVar8 >> 0x10; - m->m[1][0] = FIXED(iVar2 * iVar6); - m->m[1][1] = FIXED(iVar8 * iVar6); - iVar6 = FIXED(iVar1 * iVar5); - m->m[0][0] = FIXED(iVar7 * iVar8) + FIXED(iVar6 * iVar2); - m->m[0][1] = FIXED(iVar6 * iVar8) - FIXED(iVar7 * iVar2); - iVar5 = FIXED(iVar7 * iVar5); - m->m[2][1] = FIXED(iVar1 * iVar2) + FIXED(iVar5 * iVar8); - m->m[2][0] = FIXED(iVar5 * iVar2) - FIXED(iVar1 * iVar8); + m->m[1][0] = FIXEDH(iVar2 * iVar6); + m->m[1][1] = FIXEDH(iVar8 * iVar6); + iVar6 = FIXEDH(iVar1 * iVar5); + m->m[0][0] = FIXEDH(iVar7 * iVar8) + FIXEDH(iVar6 * iVar2); + m->m[0][1] = FIXEDH(iVar6 * iVar8) - FIXEDH(iVar7 * iVar2); + iVar5 = FIXEDH(iVar7 * iVar5); + m->m[2][1] = FIXEDH(iVar1 * iVar2) + FIXEDH(iVar5 * iVar8); + m->m[2][0] = FIXEDH(iVar5 * iVar2) - FIXEDH(iVar1 * iVar8); return m; } @@ -1464,16 +1464,16 @@ MATRIX* RotMatrixX(long r, MATRIX* m) int t1, t2; t1 = m->m[1][0]; t2 = m->m[2][0]; - m->m[1][0] = FIXED(t1 * c0 - t2 * s0); - m->m[2][0] = FIXED(t1 * s0 + t2 * c0); + m->m[1][0] = FIXEDH(t1 * c0 - t2 * s0); + m->m[2][0] = FIXEDH(t1 * s0 + t2 * c0); t1 = m->m[1][1]; t2 = m->m[2][1]; - m->m[1][1] = FIXED(t1 * c0 - t2 * s0); - m->m[2][1] = FIXED(t1 * s0 + t2 * c0); + m->m[1][1] = FIXEDH(t1 * c0 - t2 * s0); + m->m[2][1] = FIXEDH(t1 * s0 + t2 * c0); t1 = m->m[1][2]; t2 = m->m[2][2]; - m->m[1][2] = FIXED(t1 * c0 - t2 * s0); - m->m[2][2] = FIXED(t1 * s0 + t2 * c0); + m->m[1][2] = FIXEDH(t1 * c0 - t2 * s0); + m->m[2][2] = FIXEDH(t1 * s0 + t2 * c0); return m; } @@ -1485,16 +1485,16 @@ MATRIX* RotMatrixY(long r, MATRIX* m) int t1, t2; t1 = m->m[0][0]; t2 = m->m[2][0]; - m->m[0][0] = FIXED(t1 * c0 + t2 * s0); - m->m[2][0] = FIXED(-t1 * s0 + t2 * c0); + m->m[0][0] = FIXEDH(t1 * c0 + t2 * s0); + m->m[2][0] = FIXEDH(-t1 * s0 + t2 * c0); t1 = m->m[0][1]; t2 = m->m[2][1]; - m->m[0][1] = FIXED(t1 * c0 + t2 * s0); - m->m[2][1] = FIXED(-t1 * s0 + t2 * c0); + m->m[0][1] = FIXEDH(t1 * c0 + t2 * s0); + m->m[2][1] = FIXEDH(-t1 * s0 + t2 * c0); t1 = m->m[0][2]; t2 = m->m[2][2]; - m->m[0][2] = FIXED(t1 * c0 + t2 * s0); - m->m[2][2] = FIXED(-t1 * s0 + t2 * c0); + m->m[0][2] = FIXEDH(t1 * c0 + t2 * s0); + m->m[2][2] = FIXEDH(-t1 * s0 + t2 * c0); return m; } @@ -1506,16 +1506,16 @@ MATRIX* RotMatrixZ(long r, MATRIX* m) int t1, t2; t1 = m->m[0][0]; t2 = m->m[1][0]; - m->m[0][0] = FIXED(t1 * c0 - t2 * s0); - m->m[1][0] = FIXED(t1 * s0 + t2 * c0); + m->m[0][0] = FIXEDH(t1 * c0 - t2 * s0); + m->m[1][0] = FIXEDH(t1 * s0 + t2 * c0); t1 = m->m[0][1]; t2 = m->m[1][1]; - m->m[0][1] = FIXED(t1 * c0 - t2 * s0); - m->m[1][1] = FIXED(t1 * s0 + t2 * c0); + m->m[0][1] = FIXEDH(t1 * c0 - t2 * s0); + m->m[1][1] = FIXEDH(t1 * s0 + t2 * c0); t1 = m->m[0][2]; t2 = m->m[1][2]; - m->m[0][2] = FIXED(t1 * c0 - t2 * s0); - m->m[1][2] = FIXED(t1 * s0 + t2 * c0); + m->m[0][2] = FIXEDH(t1 * c0 - t2 * s0); + m->m[1][2] = FIXEDH(t1 * s0 + t2 * c0); return m; } @@ -1551,15 +1551,15 @@ MATRIX* TransMatrix(MATRIX* m, VECTOR* v) MATRIX* ScaleMatrix(MATRIX* m, VECTOR* v) { - m->m[0][0] = FIXED(m->m[0][0] * v->vx); - m->m[0][1] = FIXED(m->m[0][1] * v->vx); - m->m[0][2] = FIXED(m->m[0][2] * v->vx); - m->m[1][0] = FIXED(m->m[1][0] * v->vy); - m->m[1][1] = FIXED(m->m[1][1] * v->vy); - m->m[1][2] = FIXED(m->m[1][2] * v->vy); - m->m[2][0] = FIXED(m->m[2][0] * v->vz); - m->m[2][1] = FIXED(m->m[2][1] * v->vz); - m->m[2][2] = FIXED(m->m[2][2] * v->vz); + m->m[0][0] = FIXEDH(m->m[0][0] * v->vx); + m->m[0][1] = FIXEDH(m->m[0][1] * v->vx); + m->m[0][2] = FIXEDH(m->m[0][2] * v->vx); + m->m[1][0] = FIXEDH(m->m[1][0] * v->vy); + m->m[1][1] = FIXEDH(m->m[1][1] * v->vy); + m->m[1][2] = FIXEDH(m->m[1][2] * v->vy); + m->m[2][0] = FIXEDH(m->m[2][0] * v->vz); + m->m[2][1] = FIXEDH(m->m[2][1] * v->vz); + m->m[2][2] = FIXEDH(m->m[2][2] * v->vz); return m; } diff --git a/src_rebuild/GAME/C/AI.C b/src_rebuild/GAME/C/AI.C index f9020082..1c377f93 100644 --- a/src_rebuild/GAME/C/AI.C +++ b/src_rebuild/GAME/C/AI.C @@ -83,7 +83,7 @@ int TannerCanEnterCar(_CAR_DATA *cp, int distToCarSq) (cp->controlFlags & 2) == 0 && cp->hd.where.m[1][1] > 99) // not flipped over { - speed = FIXED(cp->hd.wheel_speed); + speed = FIXEDH(cp->hd.wheel_speed); if (speed < 0) speed = -speed; @@ -161,7 +161,7 @@ int TannerStuckInCar(int doSpeedCheck, int player_id) { if (doSpeedCheck != 0) { - speed = FIXED(cp->hd.wheel_speed); + speed = FIXEDH(cp->hd.wheel_speed); if (speed < 0) speed = -speed; diff --git a/src_rebuild/GAME/C/BCOLL3D.C b/src_rebuild/GAME/C/BCOLL3D.C index d2b9489c..0c45b357 100644 --- a/src_rebuild/GAME/C/BCOLL3D.C +++ b/src_rebuild/GAME/C/BCOLL3D.C @@ -57,7 +57,7 @@ void PointFaceCheck(_CAR_DATA *cp0, _CAR_DATA *cp1, int i, TestResult *least, in diff.vy = point.vy - cp0->hd.oBox.location.vy; diff.vz = point.vz - cp0->hd.oBox.location.vz; - depth = FIXED(diff.vx * normal.vx + diff.vy * normal.vy + diff.vz * normal.vz); + depth = FIXEDH(diff.vx * normal.vx + diff.vy * normal.vy + diff.vz * normal.vz); if (depth < 0) { @@ -80,7 +80,7 @@ void PointFaceCheck(_CAR_DATA *cp0, _CAR_DATA *cp1, int i, TestResult *least, in diff.vy = radii->vy; diff.vz = radii->vz; - partialDepth = FIXED(diff.vx * normal.vx + diff.vy * normal.vy + diff.vz * normal.vz); + partialDepth = FIXEDH(diff.vx * normal.vx + diff.vy * normal.vy + diff.vz * normal.vz); if (partialDepth < 0) { diff --git a/src_rebuild/GAME/C/BCOLLIDE.C b/src_rebuild/GAME/C/BCOLLIDE.C index afedd2c7..dfd9912f 100644 --- a/src_rebuild/GAME/C/BCOLLIDE.C +++ b/src_rebuild/GAME/C/BCOLLIDE.C @@ -107,8 +107,8 @@ int bcollided2d(CDATA2D *body, int needOverlap) do { j = 1; do { - body[i].dist[j] = FIXED(body[i].axis[j].vx * delta.vx + body[i].axis[j].vz * delta.vz); - body[i].limit[j] = body[i].length[j] + FIXED(body[k].length[j] * ac + body[k].length[1-j] * as); + body[i].dist[j] = FIXEDH(body[i].axis[j].vx * delta.vx + body[i].axis[j].vz * delta.vz); + body[i].limit[j] = body[i].length[j] + FIXEDH(body[k].length[j] * ac + body[k].length[1-j] * as); if (body[i].limit[j] < body[i].dist[j]) return 0; @@ -140,7 +140,7 @@ int bcollided2d(CDATA2D *body, int needOverlap) if (FE < 0) FE = abslim - absdist; - tmp2 = FIXED(body->axis[0].vx * body[1].axis[0].vx + body->axis[0].vz * body[1].axis[0].vz); + tmp2 = FIXEDH(body->axis[0].vx * body[1].axis[0].vx + body->axis[0].vz * body[1].axis[0].vz); if (tmp2 < 0) tmp2 = -tmp2; @@ -163,7 +163,7 @@ int bcollided2d(CDATA2D *body, int needOverlap) if (FE < 0) FE = abslim - absdist; - tmp2 = FIXED(body->axis[0].vx * body[1].axis[1].vx + body->axis[0].vz * body[1].axis[1].vz); + tmp2 = FIXEDH(body->axis[0].vx * body[1].axis[1].vx + body->axis[0].vz * body[1].axis[1].vz); if (tmp2 < 0) tmp2 = -tmp2; @@ -341,8 +341,8 @@ void bFindCollisionPoint(CDATA2D *body, CRET2D *collisionResult) collisionResult->penetration = smallest; - collisionResult->hit.vx = cd->x.vx + FIXED(cd->axis[0].vx * cd->length[0] * sign0 + cd->axis[1].vx * cd->length[1] * sign1); - collisionResult->hit.vz = cd->x.vz + FIXED(cd->axis[0].vz * cd->length[0] * sign0 + cd->axis[1].vz * cd->length[1] * sign1); + collisionResult->hit.vx = cd->x.vx + FIXEDH(cd->axis[0].vx * cd->length[0] * sign0 + cd->axis[1].vx * cd->length[1] * sign1); + collisionResult->hit.vz = cd->x.vz + FIXEDH(cd->axis[0].vz * cd->length[0] * sign0 + cd->axis[1].vz * cd->length[1] * sign1); if (besti != 0) sign = -sign; @@ -533,7 +533,7 @@ void ApplyDamage(_CAR_DATA *cp, char region, int value, char fakeDamage) pRegion = (cp->ap.damage + region); if (cp->controlType == 1 || cp->controlType == 4) - value = value * FIXED(gPlayerDamageFactor); + value = value * FIXEDH(gPlayerDamageFactor); else value = value << 1; @@ -662,8 +662,8 @@ int DamageCar3D(_CAR_DATA *cp, long(*delta)[4], int strikeVel, _CAR_DATA *pOther return 0; } - nose = FIXED(cp->hd.where.m[0][2] * (*delta)[0] + cp->hd.where.m[1][2] * (*delta)[1] + cp->hd.where.m[2][2] * (*delta)[2]); - door = FIXED(cp->hd.where.m[0][0] * (*delta)[0] + cp->hd.where.m[1][0] * (*delta)[1] + cp->hd.where.m[2][0] * (*delta)[2]); + nose = FIXEDH(cp->hd.where.m[0][2] * (*delta)[0] + cp->hd.where.m[1][2] * (*delta)[1] + cp->hd.where.m[2][2] * (*delta)[2]); + door = FIXEDH(cp->hd.where.m[0][0] * (*delta)[0] + cp->hd.where.m[1][0] * (*delta)[1] + cp->hd.where.m[2][0] * (*delta)[2]); if (door < 1) { @@ -799,8 +799,8 @@ void DamageCar(_CAR_DATA *cp, CDATA2D *cd, CRET2D *collisionResult, int strikeVe dx = collisionResult->hit.vx - cd->x.vx; dz = collisionResult->hit.vz - cd->x.vz; - nose = FIXED(cd->axis[0].vx * dx + cd->axis[0].vz * dz); - door = FIXED(cd->axis[1].vx * dx + cd->axis[1].vz * dz); + nose = FIXEDH(cd->axis[0].vx * dx + cd->axis[0].vz * dz); + door = FIXEDH(cd->axis[1].vx * dx + cd->axis[1].vz * dz); if (door < 1) { @@ -1035,8 +1035,8 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop if (cp->controlType == 6) { - cd[0].vel.vx = FIXED(cp->st.n.linearVelocity[0]); - cd[0].vel.vz = FIXED(cp->st.n.linearVelocity[2]); + cd[0].vel.vx = FIXEDH(cp->st.n.linearVelocity[0]); + cd[0].vel.vz = FIXEDH(cp->st.n.linearVelocity[2]); cp->hd.where.t[0] += cd[0].vel.vx; cp->hd.where.t[2] += cd[0].vel.vz; @@ -1053,8 +1053,8 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop } else { - cd[0].vel.vx = FIXED(cp->st.n.linearVelocity[0]); - cd[0].vel.vz = FIXED(cp->st.n.linearVelocity[2]); + cd[0].vel.vx = FIXEDH(cp->st.n.linearVelocity[0]); + cd[0].vel.vz = FIXEDH(cp->st.n.linearVelocity[2]); cp->hd.where.t[0] += cd[0].vel.vx; cp->hd.where.t[2] += cd[0].vel.vz; @@ -1069,10 +1069,10 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop } } - cd[0].avel = FIXED(cp->st.n.angularVelocity[1]) * 5 >> 5; + cd[0].avel = FIXEDH(cp->st.n.angularVelocity[1]) * 5 >> 5; - cd[1].x.vx = cp->hd.where.t[0] + (((building->pos.vx - cp->hd.where.t[0]) << 0x10) >> 0x10); - cd[1].x.vz = cp->hd.where.t[2] + (((building->pos.vz - cp->hd.where.t[2]) << 0x10) >> 0x10); + cd[1].x.vx = cp->hd.where.t[0] + (building->pos.vx - cp->hd.where.t[0]); + cd[1].x.vz = cp->hd.where.t[2] + (building->pos.vz - cp->hd.where.t[2]); cd[1].theta = building->theta; cd[1].length[0] = building->xsize; @@ -1112,10 +1112,10 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop //Debug_AddLine(b1p1, b2p1, yycv); VECTOR b1ax[2] = { {0} , {0} }; - b1ax[0].vx = FIXED(cd[0].axis[0].vx * cd[0].length[0]); - b1ax[0].vz = FIXED(cd[0].axis[0].vz * cd[0].length[0]); - b1ax[1].vx = FIXED(cd[0].axis[1].vx * cd[0].length[1]); - b1ax[1].vz = FIXED(cd[0].axis[1].vz * cd[0].length[1]); + b1ax[0].vx = FIXEDH(cd[0].axis[0].vx * cd[0].length[0]); + b1ax[0].vz = FIXEDH(cd[0].axis[0].vz * cd[0].length[0]); + b1ax[1].vx = FIXEDH(cd[0].axis[1].vx * cd[0].length[1]); + b1ax[1].vz = FIXEDH(cd[0].axis[1].vz * cd[0].length[1]); // show axis of body 1 Debug_AddLineOfs(_zero, b1ax[0], b1p, rrcv); @@ -1139,10 +1139,10 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop } VECTOR b2ax[2] = { {0} , {0} }; - b2ax[0].vx += FIXED(cd[1].axis[0].vx * cd[1].length[0]); - b2ax[0].vz += FIXED(cd[1].axis[0].vz * cd[1].length[0]); - b2ax[1].vx += FIXED(cd[1].axis[1].vx * cd[1].length[1]); - b2ax[1].vz += FIXED(cd[1].axis[1].vz * cd[1].length[1]); + b2ax[0].vx += FIXEDH(cd[1].axis[0].vx * cd[1].length[0]); + b2ax[0].vz += FIXEDH(cd[1].axis[0].vz * cd[1].length[0]); + b2ax[1].vx += FIXEDH(cd[1].axis[1].vx * cd[1].length[1]); + b2ax[1].vz += FIXEDH(cd[1].axis[1].vz * cd[1].length[1]); // show axis of body 2 Debug_AddLineOfs(_zero, b2ax[0], b2p, rrcv); @@ -1211,24 +1211,17 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop collisionResult.hit.vy = cp->hd.where.t[1] + 41; + // perform error correction + cp->hd.where.t[0] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vx); + cp->hd.where.t[2] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vz); + lever[0] = collisionResult.hit.vx - cp->hd.where.t[0]; lever[1] = collisionResult.hit.vy - cp->hd.where.t[1]; lever[2] = collisionResult.hit.vz - cp->hd.where.t[2]; - reaction[0] = FIXED(cp->st.n.angularVelocity[1] * lever[2] - cp->st.n.angularVelocity[2] * lever[1]) + cp->st.n.linearVelocity[0]; - reaction[1] = FIXED(cp->st.n.angularVelocity[2] * lever[0] - cp->st.n.angularVelocity[0] * lever[2]) + cp->st.n.linearVelocity[1]; - reaction[2] = FIXED(cp->st.n.angularVelocity[0] * lever[1] - cp->st.n.angularVelocity[1] * lever[0]) + cp->st.n.linearVelocity[2]; - - if (cp->controlType == 6) // [A] temporary hack due to physics differences - { - cp->hd.where.t[0] += FIXED(collisionResult.penetration * collisionResult.surfNormal.vx); - cp->hd.where.t[2] += FIXED(collisionResult.penetration * collisionResult.surfNormal.vz); - } - else - { - cp->st.n.fposition[0] += FIXED(collisionResult.penetration * collisionResult.surfNormal.vx) << 1; - cp->st.n.fposition[2] += FIXED(collisionResult.penetration * collisionResult.surfNormal.vz) << 1; - } + reaction[0] = FIXEDH(cp->st.n.angularVelocity[1] * lever[2] - cp->st.n.angularVelocity[2] * lever[1]) + cp->st.n.linearVelocity[0]; + reaction[1] = FIXEDH(cp->st.n.angularVelocity[2] * lever[0] - cp->st.n.angularVelocity[0] * lever[2]) + cp->st.n.linearVelocity[1]; + reaction[2] = FIXEDH(cp->st.n.angularVelocity[0] * lever[1] - cp->st.n.angularVelocity[1] * lever[0]) + cp->st.n.linearVelocity[2]; if (flags & 0x2) // [A] Vegas train velocity - added here { @@ -1256,9 +1249,9 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop collisionResult.hit.vy = -collisionResult.hit.vy; - velocity.vx = FIXED(cp->st.n.linearVelocity[0]); + velocity.vx = FixFloorSigned(cp->st.n.linearVelocity[0], ONE_BITS); velocity.vy = -17; - velocity.vz = FIXED(cp->st.n.linearVelocity[2]); + velocity.vz = FixFloorSigned(cp->st.n.linearVelocity[2], ONE_BITS); if ((model->flags2 & 0x800) != 0) { @@ -1351,46 +1344,46 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop DamageCar(cp, cd, &collisionResult, strikeVel); - displacement = FIXED(lever[0] * collisionResult.surfNormal.vx + lever[1] * collisionResult.surfNormal.vy + lever[2] * collisionResult.surfNormal.vz); - displacement = FIXED(((lever[0] * lever[0] + lever[2] * lever[2]) - displacement * displacement) * car_cos->twistRateY) + 4096; + displacement = FIXEDH(lever[0] * collisionResult.surfNormal.vx + lever[1] * collisionResult.surfNormal.vy + lever[2] * collisionResult.surfNormal.vz); + displacement = FIXEDH(((lever[0] * lever[0] + lever[2] * lever[2]) - displacement * displacement) * car_cos->twistRateY) + 4096; if (strikeVel < 0x7f001) denom = (strikeVel * 4096) / displacement; else denom = (strikeVel / displacement) * 4096; - denom /= 64; + denom = FixFloorSigned(denom, 6); - pointVel[0] = denom * (collisionResult.surfNormal.vx / 64); - pointVel[1] = denom * (collisionResult.surfNormal.vy / 64); - pointVel[2] = denom * (collisionResult.surfNormal.vz / 64); + pointVel[0] = denom * FixFloorSigned(collisionResult.surfNormal.vx, 6); + pointVel[1] = denom * FixFloorSigned(collisionResult.surfNormal.vy, 6); + pointVel[2] = denom * FixFloorSigned(collisionResult.surfNormal.vz, 6); - cp->hd.aacc[1] += FIXED(lever[2] * pointVel[0]) - FIXED(lever[0] * pointVel[2]); + cp->hd.aacc[1] += FIXEDH(lever[2] * pointVel[0]) - FIXEDH(lever[0] * pointVel[2]); if (cp->controlType != 4) { - temp = FIXED(lever[1] * pointVel[2]); + temp = FIXEDH(lever[1] * pointVel[2]); if (cp->controlType == 3) temp >>= 1; cp->hd.aacc[0] += temp; - temp = FIXED(lever[2] * pointVel[1]); + temp = FIXEDH(lever[2] * pointVel[1]); if (cp->controlType == 3) temp >>= 1; cp->hd.aacc[0] -= temp; - temp = FIXED(lever[0] * pointVel[1]); + temp = FIXEDH(lever[0] * pointVel[1]); if (cp->controlType == 3) temp >>= 1; cp->hd.aacc[2] += temp; - temp = FIXED(lever[1] * pointVel[0]); + temp = FIXEDH(lever[1] * pointVel[0]); if (cp->controlType == 3) temp >>= 1; @@ -1405,8 +1398,8 @@ int CarBuildingCollision(_CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop } } - cp->hd.where.t[0] -= FIXED(cp->st.n.linearVelocity[0]); - cp->hd.where.t[2] -= FIXED(cp->st.n.linearVelocity[2]); + cp->hd.where.t[0] -= FIXEDH(cp->st.n.linearVelocity[0]); + cp->hd.where.t[2] -= FIXEDH(cp->st.n.linearVelocity[2]); } } diff --git a/src_rebuild/GAME/C/BOMBERMAN.C b/src_rebuild/GAME/C/BOMBERMAN.C index 0357e3eb..f190a59a 100644 --- a/src_rebuild/GAME/C/BOMBERMAN.C +++ b/src_rebuild/GAME/C/BOMBERMAN.C @@ -162,9 +162,9 @@ void HandleThrownBombs(void) bomb->position.vy = gBombTargetVehicle->hd.where.t[1] - 200; bomb->position.vz = gBombTargetVehicle->hd.where.t[2]; - velocity.vx = FIXED(gBombTargetVehicle->st.n.linearVelocity[0]); + velocity.vx = FIXEDH(gBombTargetVehicle->st.n.linearVelocity[0]); velocity.vy = 0; - velocity.vz = FIXED(gBombTargetVehicle->st.n.linearVelocity[2]); + velocity.vz = FIXEDH(gBombTargetVehicle->st.n.linearVelocity[2]); bomb->velocity.vx = velocity.vx >> 10; bomb->velocity.vz = velocity.vz >> 10; @@ -215,7 +215,7 @@ void HandleThrownBombs(void) dx = (bomb->position.vx - player[0].pos[0]); dz = (bomb->position.vz - player[0].pos[2]); - if (FIXED(dx * dx + dz * dz) < 1024) + if (FIXEDH(dx * dx + dz * dz) < 1024) SetPadVibration(player[0].padid, 3); // [A] bug fix } } @@ -707,8 +707,8 @@ void ExplosionCollisionCheck(_CAR_DATA *cp, _ExOBJECT *pE) { bFindCollisionPoint(cd, &collisionResult); - cp->hd.where.t[2] += FIXED(collisionResult.penetration * collisionResult.surfNormal.vz); - cp->hd.where.t[0] += FIXED(collisionResult.penetration * collisionResult.surfNormal.vx); + cp->hd.where.t[2] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vz); + cp->hd.where.t[0] += FIXEDH(collisionResult.penetration * collisionResult.surfNormal.vx); lever[0] = collisionResult.hit.vx - cp->hd.where.t[0]; lever[1] = 60; @@ -755,8 +755,8 @@ void ExplosionCollisionCheck(_CAR_DATA *cp, _ExOBJECT *pE) DamageCar(cp, cd, &collisionResult, strikeVel); - displacement = FIXED(lever[0] * collisionResult.surfNormal.vx + lever[1] * collisionResult.surfNormal.vy + lever[2] * collisionResult.surfNormal.vz); - displacement = FIXED(((lever[0] * lever[0] + lever[2] * lever[2]) - displacement * displacement) * car_cosmetics[cp->ap.model].twistRateY) + 0x1000; + displacement = FIXEDH(lever[0] * collisionResult.surfNormal.vx + lever[1] * collisionResult.surfNormal.vy + lever[2] * collisionResult.surfNormal.vz); + displacement = FIXEDH(((lever[0] * lever[0] + lever[2] * lever[2]) - displacement * displacement) * car_cosmetics[cp->ap.model].twistRateY) + 0x1000; if (strikeVel < 0x7f001) denom = (strikeVel * 4096) / displacement; @@ -773,9 +773,9 @@ void ExplosionCollisionCheck(_CAR_DATA *cp, _ExOBJECT *pE) cp->st.n.linearVelocity[1] = cp->st.n.linearVelocity[1] + pointVel[1]; cp->st.n.linearVelocity[2] = cp->st.n.linearVelocity[2] + pointVel[2]; - cp->hd.aacc[0] = (cp->hd.aacc[0] + FIXED(lever[1] * pointVel[2])) - FIXED(lever[2] * pointVel[1]); - cp->hd.aacc[1] = (cp->hd.aacc[1] + FIXED(lever[2] * pointVel[0])) - FIXED(lever[0] * pointVel[2]); - cp->hd.aacc[2] = (cp->hd.aacc[2] + FIXED(lever[0] * pointVel[1])) - FIXED(lever[1] * pointVel[0]); + cp->hd.aacc[0] = (cp->hd.aacc[0] + FIXEDH(lever[1] * pointVel[2])) - FIXEDH(lever[2] * pointVel[1]); + cp->hd.aacc[1] = (cp->hd.aacc[1] + FIXEDH(lever[2] * pointVel[0])) - FIXEDH(lever[0] * pointVel[2]); + cp->hd.aacc[2] = (cp->hd.aacc[2] + FIXEDH(lever[0] * pointVel[1])) - FIXEDH(lever[1] * pointVel[0]); } } diff --git a/src_rebuild/GAME/C/CAMERA.C b/src_rebuild/GAME/C/CAMERA.C index 5ae84029..592efe72 100644 --- a/src_rebuild/GAME/C/CAMERA.C +++ b/src_rebuild/GAME/C/CAMERA.C @@ -334,8 +334,8 @@ void ModifyCamera(void) CalcCameraBasePos(lp); angle = baseDir + 0x800 & 0xfff; - lp->cameraPos.vx = basePos[0] + FIXED(rcossin_tbl[angle * 2] * (length - 60)); - lp->cameraPos.vz = basePos[2] + FIXED(rcossin_tbl[angle * 2 + 1] * (length - 60)); + lp->cameraPos.vx = basePos[0] + FIXEDH(rcossin_tbl[angle * 2] * (length - 60)); + lp->cameraPos.vz = basePos[2] + FIXEDH(rcossin_tbl[angle * 2 + 1] * (length - 60)); } } } @@ -668,7 +668,7 @@ void PlaceCameraFollowCar(_PLAYER *lp) carheight = car_cos->colBox.vy * -3 + 0x55; maxCameraDist = car_cos->colBox.vz * 2 + car_cos->colBox.vy + 248; - carSpeed = FIXED(camCar->hd.wheel_speed); + carSpeed = FIXEDH(camCar->hd.wheel_speed); if (carSpeed < 0) carSpeed = -carSpeed; @@ -705,8 +705,8 @@ void PlaceCameraFollowCar(_PLAYER *lp) } } - lp->cameraPos.vx = basePos[0] + FIXED(rcossin_tbl[camAngle * 2] * lp->cameraDist); - lp->cameraPos.vz = basePos[2] + FIXED(rcossin_tbl[camAngle * 2 + 1] * lp->cameraDist); + lp->cameraPos.vx = basePos[0] + FIXEDH(rcossin_tbl[camAngle * 2] * lp->cameraDist); + lp->cameraPos.vz = basePos[2] + FIXEDH(rcossin_tbl[camAngle * 2 + 1] * lp->cameraDist); lp->cameraPos.vy = basePos[1]; camPosVy = MapHeight(&lp->cameraPos); @@ -762,8 +762,8 @@ void PlaceCameraFollowCar(_PLAYER *lp) jcam->hd.direction = jcam->hd.direction & 0xfff; lp->cameraPos.vy = -jcam->hd.where.t[1]; - lp->cameraPos.vx = basePos[0] + FIXED(lp->cameraDist * rcossin_tbl[jcam->hd.direction * 2]); - lp->cameraPos.vz = basePos[2] + FIXED(lp->cameraDist * rcossin_tbl[jcam->hd.direction * 2 + 1]); + lp->cameraPos.vx = basePos[0] + FIXEDH(lp->cameraDist * rcossin_tbl[jcam->hd.direction * 2]); + lp->cameraPos.vz = basePos[2] + FIXEDH(lp->cameraDist * rcossin_tbl[jcam->hd.direction * 2 + 1]); camera_angle.vy = -ratan2(basePos[0] - lp->cameraPos.vx, basePos[2] - lp->cameraPos.vz) & 0xfff; camera_angle.vz = 0; @@ -978,9 +978,9 @@ void PlaceCameraInCar(_PLAYER *lp, int BumperCam) angle = baseDir & 0xfff; - lp->cameraPos.vx = basePos[0] + FIXED(rcossin_tbl[angle * 2] * viewer_position.vz); + lp->cameraPos.vx = basePos[0] + FIXEDH(rcossin_tbl[angle * 2] * viewer_position.vz); lp->cameraPos.vy = viewer_position.vy - basePos[1]; - lp->cameraPos.vz = basePos[2] + FIXED(rcossin_tbl[angle * 2 + 1] * viewer_position.vz); + lp->cameraPos.vz = basePos[2] + FIXEDH(rcossin_tbl[angle * 2 + 1] * viewer_position.vz); TurnHead(lp); diff --git a/src_rebuild/GAME/C/CARS.C b/src_rebuild/GAME/C/CARS.C index 5f4953c2..8343214b 100644 --- a/src_rebuild/GAME/C/CARS.C +++ b/src_rebuild/GAME/C/CARS.C @@ -1193,8 +1193,8 @@ void DrawCarWheels(_CAR_DATA *cp, MATRIX *RearMatrix, VECTOR *pos, int zclip) // rotate wheel verts - FW1z = FIXED(rcossin_tbl[(FrontWheelRotation[car_id] & 0xfff) * 2] * sizeScale); - FW2z = FIXED(rcossin_tbl[(FrontWheelRotation[car_id] & 0xfff) * 2 + 1] * sizeScale); + FW1z = FIXEDH(rcossin_tbl[(FrontWheelRotation[car_id] & 0xfff) * 2] * sizeScale); + FW2z = FIXEDH(rcossin_tbl[(FrontWheelRotation[car_id] & 0xfff) * 2 + 1] * sizeScale); VertPtr = (SVECTOR*)WheelModelFront->vertices; @@ -1237,8 +1237,8 @@ void DrawCarWheels(_CAR_DATA *cp, MATRIX *RearMatrix, VECTOR *pos, int zclip) VertPtr[17].vy = -wheelSize; VertPtr[16].vy = -wheelSize; - BW1z = FIXED(rcossin_tbl[(BackWheelRotation[car_id] & 0xfff) * 2] * sizeScale); - BW2z = FIXED(rcossin_tbl[(BackWheelRotation[car_id] & 0xfff) * 2 + 1] * sizeScale); + BW1z = FIXEDH(rcossin_tbl[(BackWheelRotation[car_id] & 0xfff) * 2] * sizeScale); + BW2z = FIXEDH(rcossin_tbl[(BackWheelRotation[car_id] & 0xfff) * 2 + 1] * sizeScale); VertPtr = (SVECTOR *)WheelModelBack->vertices; diff --git a/src_rebuild/GAME/C/CIV_AI.C b/src_rebuild/GAME/C/CIV_AI.C index 4319dffc..4bba5d88 100644 --- a/src_rebuild/GAME/C/CIV_AI.C +++ b/src_rebuild/GAME/C/CIV_AI.C @@ -894,7 +894,7 @@ int GetNextRoadInfo(_CAR_DATA *cp, int randomExit, int *turnAngle, int *startDis uVar9 = (uint)(ushort)___st->angle & 0xfff; uVar29 = (u_char)___st->NumLanes & 0xffffff0f; test555 = (oldNode->x - ___st->Midx) * (int)rcossin_tbl[uVar9 * 2 + 1] - (oldNode->z - ___st->Midz) * (int)rcossin_tbl[uVar9 * 2]; - test42 = uVar29 - (FIXED(test555) + 512 >> 9); + test42 = uVar29 - (FIXEDH(test555) + 512 >> 9); *piVar25 = test42; unaff_s8 = uVar29 * 2; uVar29 = ((u_char)___st->NumLanes & 0xffffff0f) * 2; @@ -2288,10 +2288,10 @@ void InitNodeList(_CAR_DATA *cp, EXTRA_CIV_DATA *extraData) sVar1 = straight->angle; lVar4 = SquareRoot0(y * y + x * x); - cr->distAlongSegment = (straight->length >> 1) + FIXED(rcossin_tbl[(sVar1 - lVar3 & 0xfffU) * 2 + 1] * lVar4); + cr->distAlongSegment = (straight->length >> 1) + FIXEDH(rcossin_tbl[(sVar1 - lVar3 & 0xfffU) * 2 + 1] * lVar4); uVar5 = straight->angle & 0xfff; - y = (straight->NumLanes & 0xf) * 0x200 + FIXED(-y * rcossin_tbl[uVar5 * 2 + 1] + x * rcossin_tbl[uVar5 * 2]); + y = (straight->NumLanes & 0xf) * 0x200 + FIXEDH(-y * rcossin_tbl[uVar5 * 2 + 1] + x * rcossin_tbl[uVar5 * 2]); uVar5 = y >> 9; cp->ai.c.currentLane = uVar5; @@ -2411,12 +2411,12 @@ int GetNodePos(DRIVER2_STRAIGHT *straight, DRIVER2_JUNCTION *junction, DRIVER2_C sideShift = ((straight->NumLanes & 0xf) * 0x200 - (laneNo * 0x200 + 0x100)) + test42; *x = straight->Midx + - FIXED(distFromCentre * rcossin_tbl[(angle & 0xfffU) * 2]) + - FIXED(sideShift * rcossin_tbl[(angle & 0xfffU) * 2 + 1]); + FIXEDH(distFromCentre * rcossin_tbl[(angle & 0xfffU) * 2]) + + FIXEDH(sideShift * rcossin_tbl[(angle & 0xfffU) * 2 + 1]); *z = (straight->Midz + - FIXED(distFromCentre * rcossin_tbl[(angle & 0xfffU) * 2 + 1])) - - FIXED(sideShift * rcossin_tbl[(angle & 0xfffU) * 2]); + FIXEDH(distFromCentre * rcossin_tbl[(angle & 0xfffU) * 2 + 1])) - + FIXEDH(sideShift * rcossin_tbl[(angle & 0xfffU) * 2]); goto LAB_00026f00; } @@ -2441,8 +2441,8 @@ int GetNodePos(DRIVER2_STRAIGHT *straight, DRIVER2_JUNCTION *junction, DRIVER2_C test42 = uVar1 * 0x80; radius = curve->inside * 0x400 + laneNo * 0x200 + 0x100 + test42; - *x = curve->Midx + FIXED(radius * rcossin_tbl[(angle & 0xfffU) * 2]); - *z = curve->Midz + FIXED(radius * rcossin_tbl[(angle & 0xfffU) * 2 + 1]); + *x = curve->Midx + FIXEDH(radius * rcossin_tbl[(angle & 0xfffU) * 2]); + *z = curve->Midz + FIXEDH(radius * rcossin_tbl[(angle & 0xfffU) * 2 + 1]); LAB_00026f00: if (uVar3 != 0) { @@ -2618,8 +2618,8 @@ int CheckChangeLanes(DRIVER2_STRAIGHT *straight, DRIVER2_CURVE *curve, int distA uVar8 = iVar6 + 0x400; } - cd[0].x.vx = (cp->hd).oBox.location.vx + FIXED((int)rcossin_tbl[(uVar8 & 0xfff) * 2] * 0x200); - cd[0].x.vz = (cp->hd).oBox.location.vz + FIXED((int)rcossin_tbl[(uVar8 & 0xfff) * 2 + 1] * 0x200); + cd[0].x.vx = (cp->hd).oBox.location.vx + FIXEDH((int)rcossin_tbl[(uVar8 & 0xfff) * 2] * 0x200); + cd[0].x.vz = (cp->hd).oBox.location.vz + FIXEDH((int)rcossin_tbl[(uVar8 & 0xfff) * 2 + 1] * 0x200); cd[0].length[0] = (int)(((cp->ap).carCos)->colBox).vz + 0x5d; cd[0].length[1] = (int)(((cp->ap).carCos)->colBox).vx; cd[0].theta = (cp->hd).direction; @@ -3349,14 +3349,14 @@ int CreateNewNode(_CAR_DATA *cp) lVar2 = SquareRoot0(y * y + x * x); lVar3 = ratan2(y, x); local_a3_2384 = ((lVar3 - local_v1_48->dir) + 0x800U & 0xfff) - 0x800; - x = FIXED((lVar2 - iVar6) * (int)rcossin_tbl[(local_a3_2384 & 0xfffU) * 2 + 1]); + x = FIXEDH((lVar2 - iVar6) * (int)rcossin_tbl[(local_a3_2384 & 0xfffU) * 2 + 1]); pCVar5 = pCVar4; if (0 < x) { - pCVar4->x = local_v1_48->x + FIXED(x * rcossin_tbl[((uint)(ushort)local_v1_48->dir & 0xfff) * 2]); + pCVar4->x = local_v1_48->x + FIXEDH(x * rcossin_tbl[((uint)(ushort)local_v1_48->dir & 0xfff) * 2]); pCVar5 = pCVar4 + 1; - pCVar4->z = local_v1_48->z + FIXED(x * rcossin_tbl[((uint)(ushort)local_v1_48->dir & 0xfff) * 2 + 1]); + pCVar4->z = local_v1_48->z + FIXEDH(x * rcossin_tbl[((uint)(ushort)local_v1_48->dir & 0xfff) * 2 + 1]); sVar1 = local_v1_48->dir; pCVar4->pathType = 1; pCVar4->dir = sVar1; @@ -3365,14 +3365,14 @@ int CreateNewNode(_CAR_DATA *cp) } } - iVar6 = FIXED((lVar2 - iVar6) * (int)rcossin_tbl[(local_a3_2384 & 0xfffU) * 2]); + iVar6 = FIXEDH((lVar2 - iVar6) * (int)rcossin_tbl[(local_a3_2384 & 0xfffU) * 2]); pCVar4 = pCVar5; if (iVar6 < 0) { - pCVar5->x = tempNode.x + FIXED(iVar6 * rcossin_tbl[(tempNode.dir & 0xfff) * 2]); + pCVar5->x = tempNode.x + FIXEDH(iVar6 * rcossin_tbl[(tempNode.dir & 0xfff) * 2]); pCVar4 = pCVar5 + 1; - pCVar5->z = tempNode.z + FIXED(iVar6 * rcossin_tbl[(tempNode.dir & 0xfff) * 2 + 1]); + pCVar5->z = tempNode.z + FIXEDH(iVar6 * rcossin_tbl[(tempNode.dir & 0xfff) * 2 + 1]); pCVar5->pathType = 1; pCVar5->dir = tempNode.dir; if (local_a1_52 <= pCVar4) @@ -4068,7 +4068,7 @@ int CreateCivCarWotDrivesABitThenStops(int direction, long(*startPos)[4], long(* pNewCar->st.n.linearVelocity[0] = EVENT_CAR_SPEED * rcossin_tbl[(direction & 0xfffU) * 2]; pNewCar->st.n.linearVelocity[2] = EVENT_CAR_SPEED * rcossin_tbl[(direction & 0xfffU) * 2 + 1]; - pNewCar->ai.c.velRatio = FIXED(EVENT_CAR_SPEED) / (DistanceTriggerCarMoves - pNewCar->ap.carCos->colBox.vz * 3); + pNewCar->ai.c.velRatio = FIXEDH(EVENT_CAR_SPEED) / (DistanceTriggerCarMoves - pNewCar->ap.carCos->colBox.vz * 3); pNewCar->ai.c.targetRoute[0].x = (*startPos)[0]; pNewCar->ai.c.targetRoute[0].z = (*startPos)[2]; @@ -4079,16 +4079,16 @@ int CreateCivCarWotDrivesABitThenStops(int direction, long(*startPos)[4], long(* stopNode->dir = direction; stopNode->distAlongSegment = 0; - stopNode->x = (*startPos)[0] + FIXED(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2]); - stopNode->z = (*startPos)[2] + FIXED(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2 + 1]); + stopNode->x = (*startPos)[0] + FIXEDH(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2]); + stopNode->z = (*startPos)[2] + FIXEDH(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2 + 1]); spareNode = &pNewCar->ai.c.targetRoute[2]; spareNode->pathType = 1; spareNode->dir = direction; spareNode->distAlongSegment = 0; - spareNode->x = (*startPos)[0] + FIXED(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2] * 3); - spareNode->z = (*startPos)[2] + FIXED(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2 + 1] * 3); + spareNode->x = (*startPos)[0] + FIXEDH(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2] * 3); + spareNode->z = (*startPos)[2] + FIXEDH(DistanceTriggerCarMoves * rcossin_tbl[(direction & 0xfffU) * 2 + 1] * 3); numCivCars++; @@ -4219,19 +4219,19 @@ int CreateStationaryCivCar(int direction, long orientX, long orientZ, long(*star iVar7 = (int)*(short *)((int)rcossin_tbl + uVar6); iVar4 = (int)*(short *)((int)rcossin_tbl + uVar6 + 2); - tmpQ[0] = FIXED(cp->st.n.orientation[1] * iVar7 + cp->st.n.orientation[0] * iVar4); - tmpQ[1] = FIXED(cp->st.n.orientation[1] * iVar4 - cp->st.n.orientation[0] * iVar7); - tmpQ[2] = FIXED(cp->st.n.orientation[3] * iVar7 + cp->st.n.orientation[2] * iVar4); - tmpQ[3] = FIXED(cp->st.n.orientation[3] * iVar4 - cp->st.n.orientation[2] * iVar7); + tmpQ[0] = FIXEDH(cp->st.n.orientation[1] * iVar7 + cp->st.n.orientation[0] * iVar4); + tmpQ[1] = FIXEDH(cp->st.n.orientation[1] * iVar4 - cp->st.n.orientation[0] * iVar7); + tmpQ[2] = FIXEDH(cp->st.n.orientation[3] * iVar7 + cp->st.n.orientation[2] * iVar4); + tmpQ[3] = FIXEDH(cp->st.n.orientation[3] * iVar4 - cp->st.n.orientation[2] * iVar7); uVar6 = (orientX - (orientX >> 0x1f)) * 2 & 0x3ffc; iVar5 = (int)*(short *)((int)rcossin_tbl + uVar6); iVar7 = (int)*(short *)((int)rcossin_tbl + uVar6 + 2); - cp->st.n.orientation[0] = FIXED(tmpQ[3] * iVar5 + tmpQ[0] * iVar7); - cp->st.n.orientation[1] = FIXED(tmpQ[2] * iVar5 + tmpQ[1] * iVar7); - cp->st.n.orientation[2] = FIXED(tmpQ[2] * iVar7 - tmpQ[1] * iVar5); - cp->st.n.orientation[3] = FIXED(tmpQ[3] * iVar7 - tmpQ[0] * iVar5); + cp->st.n.orientation[0] = FIXEDH(tmpQ[3] * iVar5 + tmpQ[0] * iVar7); + cp->st.n.orientation[1] = FIXEDH(tmpQ[2] * iVar5 + tmpQ[1] * iVar7); + cp->st.n.orientation[2] = FIXEDH(tmpQ[2] * iVar7 - tmpQ[1] * iVar5); + cp->st.n.orientation[3] = FIXEDH(tmpQ[3] * iVar7 - tmpQ[0] * iVar5); numCivCars++; @@ -4588,7 +4588,7 @@ int PingInCivCar(int minPingInDist) else iVar6 = rcossin_tbl[(model & 0xfff) * 2] * 10; - randomLoc.vx = baseLoc.vx + FIXED(iVar6) * 0x800; + randomLoc.vx = baseLoc.vx + FIXEDH(iVar6) * 0x800; if (requestCopCar == 0) model = (cookieCount * 0x1000) / 0x2c; @@ -4600,7 +4600,7 @@ int PingInCivCar(int minPingInDist) else iVar6 = rcossin_tbl[(model & 0xfff) * 2 + 1] * 10; - randomLoc.vz = baseLoc.vz + FIXED(iVar6) * 0x800; + randomLoc.vz = baseLoc.vz + FIXEDH(iVar6) * 0x800; roadSeg = RoadInCell(&randomLoc); } while (((((roadSeg & 0xffffe000U) != 0) || @@ -4670,7 +4670,7 @@ int PingInCivCar(int minPingInDist) else iVar6 = rcossin_tbl[(model & 0xfff) * 2] * 10; - randomLoc.vx = baseLoc.vx + FIXED(iVar6) * 0x800; + randomLoc.vx = baseLoc.vx + FIXEDH(iVar6) * 0x800; if (requestCopCar == 0) model = (cookieCount * 0x1000) / 0x2c; @@ -4682,7 +4682,7 @@ int PingInCivCar(int minPingInDist) else iVar6 = rcossin_tbl[(model & 0xfff) * 2 + 1] * 10; - randomLoc.vz = baseLoc.vz + FIXED(iVar6) * 0x800; + randomLoc.vz = baseLoc.vz + FIXEDH(iVar6) * 0x800; roadSeg = RoadInCell(&randomLoc); } @@ -4931,7 +4931,7 @@ int PingInCivCar(int minPingInDist) lVar9 = SquareRoot0(dx * dx + dz * dz); uVar3 = straight->length; - civDat.distAlongSegment = (uVar3 >> 1) + FIXED(rcossin_tbl[(sVar2 - lVar8 & 0xfffU) * 2 + 1] * lVar9); + civDat.distAlongSegment = (uVar3 >> 1) + FIXEDH(rcossin_tbl[(sVar2 - lVar8 & 0xfffU) * 2 + 1] * lVar9); if (requestCopCar == 0) { @@ -5569,7 +5569,7 @@ int CivAccelTrafficRules(_CAR_DATA *cp, int *distToNode) goto LAB_0002a800; iVar5 = (cp->hd).wheel_speed; - iVar9 = (iVar5 * FIXED(iVar5)) / (newAccel << 1); + iVar9 = (iVar5 * FIXEDH(iVar5)) / (newAccel << 1); if (iVar9 < 0) iVar9 = -iVar9; @@ -5601,7 +5601,7 @@ int CivAccelTrafficRules(_CAR_DATA *cp, int *distToNode) } cp->ai.c.thrustState = 1; LAB_0002a800: - if (FIXED(cp->hd.wheel_speed) > cp->ai.c.maxSpeed) + if (FIXEDH(cp->hd.wheel_speed) > cp->ai.c.maxSpeed) { iVar10 = newAccel; return iVar10 >> 2; @@ -5694,11 +5694,11 @@ int CivAccelTrafficRules(_CAR_DATA *cp, int *distToNode) iVar7 = (p_Var8->hd).where.t[0] - (cp->hd).where.t[0]; iVar6 = (p_Var8->hd).where.t[2] - (cp->hd).where.t[2]; - iVar5 = FIXED(iVar7 * rcossin_tbl[uVar4 * 2] + iVar6 * rcossin_tbl[uVar4 * 2 + 1]); + iVar5 = FIXEDH(iVar7 * rcossin_tbl[uVar4 * 2] + iVar6 * rcossin_tbl[uVar4 * 2 + 1]); if (0 < iVar5) { - iVar6 = FIXED(iVar7 * rcossin_tbl[uVar4 * 2 + 1] - iVar6 * rcossin_tbl[uVar4 * 2]); + iVar6 = FIXEDH(iVar7 * rcossin_tbl[uVar4 * 2 + 1] - iVar6 * rcossin_tbl[uVar4 * 2]); if (iVar6 < 0) iVar6 = -iVar6; @@ -5922,7 +5922,7 @@ void SetUpCivCollFlags(void) do { if (local_2c->controlType == 2) { - y = FIXED(local_2c->hd.wheel_speed); + y = FIXEDH(local_2c->hd.wheel_speed); if (local_2c->wheel_angle < 0x3d) y = y * 0xd; @@ -6288,7 +6288,7 @@ int CivAccel(_CAR_DATA *cp) if (cp->ai.c.carPauseCnt > 0 && collDat == 0) { iVar5 = cp->hd.wheel_speed; - iVar4 = FIXED(iVar5); + iVar4 = FIXEDH(iVar5); if (iVar4 < 0) iVar4 = -iVar4; @@ -6584,7 +6584,7 @@ int CivSteerAngle(_CAR_DATA *cp) if (pCVar8->pathType != 127) { - CivFindPointOnPath(cp, iVar4 + FIXED(iVar3) * checkFrames + sVar2, &pathPoint); + CivFindPointOnPath(cp, iVar4 + FIXEDH(iVar3) * checkFrames + sVar2, &pathPoint); lVar5 = ratan2(pathPoint.vx - cp->hd.where.t[0], pathPoint.vz - cp->hd.where.t[2]); @@ -6996,8 +6996,8 @@ int CivFindPointOnPath(_CAR_DATA *cp, int station, VECTOR *ppoint) { stepSize >>= 4; - ppoint->vx = sx + FIXED(((dx * 256) / stepSize) * station); - ppoint->vz = sz + FIXED(((dz * 256) / stepSize) * station); + ppoint->vx = sx + FIXEDH(((dx * 256) / stepSize) * station); + ppoint->vz = sz + FIXEDH(((dz * 256) / stepSize) * station); } return 1; @@ -7223,14 +7223,14 @@ void CreateRoadblock(void) else laneNo = (int)rcossin_tbl[(iVar12 + angle & 0xfffU) * 2] * 10; - roadblockLoc.vx = baseLoc.vx + FIXED(laneNo) * 0x800; + roadblockLoc.vx = baseLoc.vx + FIXEDH(laneNo) * 0x800; if (requestCopCar == 0) laneNo = (int)rcossin_tbl[(iVar12 + angle & 0xfffU) * 2 + 1] << 3; else laneNo = (int)rcossin_tbl[(iVar12 + angle & 0xfffU) * 2 + 1] * 10; - roadblockLoc.vz = baseLoc.vz + FIXED(laneNo) * 0x800; + roadblockLoc.vz = baseLoc.vz + FIXEDH(laneNo) * 0x800; roadSeg = RoadInCell(&roadblockLoc); @@ -7245,14 +7245,14 @@ void CreateRoadblock(void) else laneNo = (int)rcossin_tbl[(iVar12 - angle & 0xfffU) * 2] * 10; - roadblockLoc.vx = baseLoc.vx + FIXED(laneNo) * 0x800; + roadblockLoc.vx = baseLoc.vx + FIXEDH(laneNo) * 0x800; if (requestCopCar == 0) laneNo = (int)rcossin_tbl[(iVar12 - angle & 0xfffU) * 2 + 1] << 3; else laneNo = (int)rcossin_tbl[(iVar12 - angle & 0xfffU) * 2 + 1] * 10; - roadblockLoc.vz = baseLoc.vz + FIXED(laneNo) * 0x800; + roadblockLoc.vz = baseLoc.vz + FIXEDH(laneNo) * 0x800; roadSeg = RoadInCell(&roadblockLoc); @@ -7291,7 +7291,7 @@ void CreateRoadblock(void) lVar7 = SquareRoot0(dx * dx + dz * dz); uVar10 = (uint)str->length; uVar8 = z_00 * 3; - distAlongSegment = (uint)(str->length >> 1) + FIXED(rcossin_tbl[(sVar3 - lVar6 & 0xfffU) * 2 + 1] * lVar7); + distAlongSegment = (uint)(str->length >> 1) + FIXEDH(rcossin_tbl[(sVar3 - lVar6 & 0xfffU) * 2 + 1] * lVar7); if ((int)uVar10 < z_00 * 6) return; @@ -7355,8 +7355,8 @@ LAB_0002c33c: if (0x100 < laneNo * 0x200) { do { - currentPos.vx = startPos.vx + FIXED(iVar12 * rcossin_tbl[(uVar8 & 0xfff) * 2] ); - currentPos.vz = startPos.vz + FIXED(iVar12 * rcossin_tbl[(uVar8 & 0xfff) * 2 + 1]); + currentPos.vx = startPos.vx + FIXEDH(iVar12 * rcossin_tbl[(uVar8 & 0xfff) * 2] ); + currentPos.vz = startPos.vz + FIXEDH(iVar12 * rcossin_tbl[(uVar8 & 0xfff) * 2 + 1]); if (str == NULL) { @@ -7479,8 +7479,8 @@ LAB_0002c33c: uVar10 = uVar8 - laneNo; uVar11 = uVar8 + laneNo & 0xfff; - laneNo = startPos.vx + FIXED((int)rcossin_tbl[uVar11 * 2] * 0x5dc); - iVar12 = startPos.vz + FIXED((int)rcossin_tbl[uVar11 * 2 + 1] * 0x5dc); + laneNo = startPos.vx + FIXEDH((int)rcossin_tbl[uVar11 * 2] * 0x5dc); + iVar12 = startPos.vz + FIXEDH((int)rcossin_tbl[uVar11 * 2 + 1] * 0x5dc); z_00 = (maxCivCars - numCivCars) + 2; x = numLanes / 2 + -1; @@ -7499,8 +7499,8 @@ LAB_0002c33c: x_00 = ((x * (z + 1)) / (iVar13 << 1)) * 0x400; z = x_00 + 0x300; - currentPos.vx = laneNo + FIXED(z * rcossin_tbl[(uVar8 & 0xfff) * 2]); - currentPos.vz = iVar12 + FIXED(z * rcossin_tbl[(uVar8 & 0xfff) * 2 + 1]); + currentPos.vx = laneNo + FIXEDH(z * rcossin_tbl[(uVar8 & 0xfff) * 2]); + currentPos.vz = iVar12 + FIXEDH(z * rcossin_tbl[(uVar8 & 0xfff) * 2 + 1]); test42 = z; lVar6 = Random2(0); diff --git a/src_rebuild/GAME/C/COP_AI.C b/src_rebuild/GAME/C/COP_AI.C index 4207abfc..301ffc4c 100644 --- a/src_rebuild/GAME/C/COP_AI.C +++ b/src_rebuild/GAME/C/COP_AI.C @@ -188,8 +188,8 @@ void WibbleDownTheRoad(VECTOR *from, int distance, VECTOR *to) } dir.vy = 0; - dir.vx = FIXED((distance >> 2) * rcossin_tbl[(val & 0xfff) * 2]); - dir.vz = FIXED((distance >> 2) * rcossin_tbl[(val & 0xfff) * 2 + 1]); + dir.vx = FIXEDH((distance >> 2) * rcossin_tbl[(val & 0xfff) * 2]); + dir.vz = FIXEDH((distance >> 2) * rcossin_tbl[(val & 0xfff) * 2 + 1]); thl[j] = val; @@ -412,8 +412,8 @@ void ControlCops(void) VECTOR v1 = *(VECTOR*)targetVehicle->hd.where.t; VECTOR v2 = v1; - v2.vx -= FIXED(targetVehicle->hd.where.m[2][0] * 1024); - v2.vz += FIXED(targetVehicle->hd.where.m[2][2] * 1024); + v2.vx -= FIXEDH(targetVehicle->hd.where.m[2][0] * 1024); + v2.vz += FIXEDH(targetVehicle->hd.where.m[2][2] * 1024); int result = lineClear(&v1, &v2); @@ -748,7 +748,7 @@ void CopControl1(_CAR_DATA *cp) desiredSteerAngle = 0; cp->wheelspin = 0; - currentSpeed = FIXED(cp->hd.wheel_speed); + currentSpeed = FIXEDH(cp->hd.wheel_speed); if (CopsAllowed == 0) { @@ -792,9 +792,9 @@ void CopControl1(_CAR_DATA *cp) if ((CameraCnt & 7U) == 0) { - pos.vx = cp->hd.where.t[0] + FIXED(cp->hd.where.m[0][2] * 400 - cp->hd.where.m[0][0] * 150); - pos.vy = cp->hd.where.t[1] + FIXED(cp->hd.where.m[1][2] * 400 - cp->hd.where.m[1][0] * 150); - pos.vz = cp->hd.where.t[2] + FIXED(cp->hd.where.m[2][2] * 400 - cp->hd.where.m[2][0] * 150); + pos.vx = cp->hd.where.t[0] + FIXEDH(cp->hd.where.m[0][2] * 400 - cp->hd.where.m[0][0] * 150); + pos.vy = cp->hd.where.t[1] + FIXEDH(cp->hd.where.m[1][2] * 400 - cp->hd.where.m[1][0] * 150); + pos.vz = cp->hd.where.t[2] + FIXEDH(cp->hd.where.m[2][2] * 400 - cp->hd.where.m[2][0] * 150); cp->ai.p.frontLClear = CellAtPositionEmpty(&pos, 80); #ifdef COLLISION_DEBUG @@ -813,9 +813,9 @@ void CopControl1(_CAR_DATA *cp) } #endif - pos.vx = cp->hd.where.t[0] + FIXED(cp->hd.where.m[0][2] * 400 + cp->hd.where.m[0][0] * 150); - pos.vy = cp->hd.where.t[1] + FIXED(cp->hd.where.m[1][2] * 400 + cp->hd.where.m[1][0] * 150); - pos.vz = cp->hd.where.t[2] + FIXED(cp->hd.where.m[2][2] * 400 + cp->hd.where.m[2][0] * 150); + pos.vx = cp->hd.where.t[0] + FIXEDH(cp->hd.where.m[0][2] * 400 + cp->hd.where.m[0][0] * 150); + pos.vy = cp->hd.where.t[1] + FIXEDH(cp->hd.where.m[1][2] * 400 + cp->hd.where.m[1][0] * 150); + pos.vz = cp->hd.where.t[2] + FIXEDH(cp->hd.where.m[2][2] * 400 + cp->hd.where.m[2][0] * 150); cp->ai.p.frontRClear = CellAtPositionEmpty(&pos, 80); #ifdef COLLISION_DEBUG @@ -874,8 +874,8 @@ void CopControl1(_CAR_DATA *cp) { if (dist < 8400) { - iVar11 = FIXED(dvx); - dvx = FIXED(dvz); + iVar11 = FIXEDH(dvx); + dvx = FIXEDH(dvz); dvz = iVar11 * iVar11 + dvx * dvx + 1; dvx = ((x - targetVehicle->hd.where.t[0]) * iVar11 - (targetVehicle->hd.where.t[2] - z) * dvx) / dvz; @@ -894,8 +894,8 @@ void CopControl1(_CAR_DATA *cp) else if (dvx > 60) dvx = 60; - dvz = targetVehicle->hd.where.t[0] + FIXED(targetVehicle->st.n.linearVelocity[0] * dvx); - dvx = targetVehicle->hd.where.t[2] + FIXED(targetVehicle->st.n.linearVelocity[2] * dvx); + dvz = targetVehicle->hd.where.t[0] + FIXEDH(targetVehicle->st.n.linearVelocity[0] * dvx); + dvx = targetVehicle->hd.where.t[2] + FIXEDH(targetVehicle->st.n.linearVelocity[2] * dvx); if (gBatterPlayer == 0) { @@ -971,9 +971,9 @@ void CopControl1(_CAR_DATA *cp) if (targetFound) { - dvz = FIXED(cp->hd.where.m[0][0] * cp->st.n.linearVelocity[0] + cp->hd.where.m[2][0] * cp->st.n.linearVelocity[2]); - dvx = FIXED((x - targetPoint.vx) * cp->hd.where.m[2][0] + (targetPoint.vz - z) * cp->hd.where.m[0][0]); - iVar5 = FIXED((targetPoint.vx - x) * cp->hd.where.m[0][0] + (targetPoint.vz - z) * cp->hd.where.m[2][0]) - dvz / 140; + dvz = FIXEDH(cp->hd.where.m[0][0] * cp->st.n.linearVelocity[0] + cp->hd.where.m[2][0] * cp->st.n.linearVelocity[2]); + dvx = FIXEDH((x - targetPoint.vx) * cp->hd.where.m[2][0] + (targetPoint.vz - z) * cp->hd.where.m[0][0]); + iVar5 = FIXEDH((targetPoint.vx - x) * cp->hd.where.m[0][0] + (targetPoint.vz - z) * cp->hd.where.m[2][0]) - dvz / 140; if (iVar5 < 1) { @@ -1026,7 +1026,7 @@ void CopControl1(_CAR_DATA *cp) iVar5 = gCopDesiredSpeedScale; } - cp->ai.p.desiredSpeed = FIXED(cp->ai.p.desiredSpeed * (iVar5 + FIXED(*psVar9 * gCopData.autoDesiredSpeedScaleLimit))); + cp->ai.p.desiredSpeed = FIXEDH(cp->ai.p.desiredSpeed * (iVar5 + FIXEDH(*psVar9 * gCopData.autoDesiredSpeedScaleLimit))); if (gPuppyDogCop != 0 && cp->ai.p.close_pursuit != 0) { @@ -1090,7 +1090,7 @@ void CopControl1(_CAR_DATA *cp) if (plcrspd < 20) plcrspd = 20; - cp->ai.p.desiredSpeed = FIXED(dist * cp->ai.p.desiredSpeed + (4096 - dist) * plcrspd); + cp->ai.p.desiredSpeed = FIXEDH(dist * cp->ai.p.desiredSpeed + (4096 - dist) * plcrspd); } iVar5 = (gCopDifficultyLevel + 8) * 0x400; @@ -1104,7 +1104,7 @@ void CopControl1(_CAR_DATA *cp) else psVar9 = &car_data[(int)player[0].playerCarId].felonyRating; - iVar5 = FIXED(iVar5 * (gCopMaxPowerScale + FIXED(*psVar9 * gCopData.autoMaxPowerScaleLimit))); + iVar5 = FIXEDH(iVar5 * (gCopMaxPowerScale + FIXEDH(*psVar9 * gCopData.autoMaxPowerScaleLimit))); sVar13 = iVar5; if (currentSpeed < -50) @@ -1950,7 +1950,7 @@ void ControlNumberOfCops(void) psVar2 = &car_data[(int)player[0].playerCarId].felonyRating; - if (iVar8 * FIXED(0x1000 - FIXED(*psVar2 * gCopData.autoRespawnScaleLimit)) < cop_respawn_timer + 1) + if (iVar8 * FIXEDH(0x1000 - FIXEDH(*psVar2 * gCopData.autoRespawnScaleLimit)) < cop_respawn_timer + 1) requestCopCar = 1; cop_respawn_timer++; diff --git a/src_rebuild/GAME/C/COSMETIC.C b/src_rebuild/GAME/C/COSMETIC.C index bb71b24d..d848299f 100644 --- a/src_rebuild/GAME/C/COSMETIC.C +++ b/src_rebuild/GAME/C/COSMETIC.C @@ -991,8 +991,8 @@ void AddExhaustSmoke(_CAR_DATA *cp, int black_smoke, int WheelSpeed) Drift.vx /= 2; Drift.vz /= 2; - Drift.vx -= FIXED(smokedir.vx) / 2; - Drift.vz -= FIXED(smokedir.vz) / 2; + Drift.vx -= FIXEDH(smokedir.vx) / 2; + Drift.vz -= FIXEDH(smokedir.vz) / 2; if (black_smoke == 0) Setup_Smoke(&SmokePos, 10, 40, 2, WheelSpeed, &Drift, 1); diff --git a/src_rebuild/GAME/C/DEBRIS.C b/src_rebuild/GAME/C/DEBRIS.C index 4bb0d26f..8bb041d9 100644 --- a/src_rebuild/GAME/C/DEBRIS.C +++ b/src_rebuild/GAME/C/DEBRIS.C @@ -593,9 +593,9 @@ void PlacePoolForCar(_CAR_DATA *cp, CVECTOR *col, int front, int in_car) iVar14++; } - iVar16 = FIXED(s[0].vx * s[1].vy - s[0].vy * s[1].vx) * s[2].vz; - iVar5 = FIXED(s[0].vy * s[1].vz - s[0].vz * s[1].vy) * s[2].vx + - FIXED(s[0].vz * s[1].vx - s[0].vx * s[1].vz) * s[2].vy + iVar16; + iVar16 = FIXEDH(s[0].vx * s[1].vy - s[0].vy * s[1].vx) * s[2].vz; + iVar5 = FIXEDH(s[0].vy * s[1].vz - s[0].vz * s[1].vy) * s[2].vx + + FIXEDH(s[0].vz * s[1].vx - s[0].vx * s[1].vz) * s[2].vy + iVar16; if (-1 < iVar5) { @@ -2398,8 +2398,8 @@ void AddTrafficLight(CELL_OBJECT *cop, int x, int y, int z, int flag, int yang) uVar3 = yang & 0xfff; v1.vy = (cop->pos.vy - camera_position.vy) + y; - v1.vx = (cop->pos.vx - camera_position.vx) + FIXED(rcossin_tbl[uVar3 * 2 + 1] * x + rcossin_tbl[uVar3 * 2] * z); - v1.vz = (cop->pos.vz - camera_position.vz) + FIXED(rcossin_tbl[uVar3 * 2 + 1] * z - rcossin_tbl[uVar3 * 2] * x); + v1.vx = (cop->pos.vx - camera_position.vx) + FIXEDH(rcossin_tbl[uVar3 * 2 + 1] * x + rcossin_tbl[uVar3 * 2] * z); + v1.vz = (cop->pos.vz - camera_position.vz) + FIXEDH(rcossin_tbl[uVar3 * 2 + 1] * z - rcossin_tbl[uVar3 * 2] * x); if ((flag & 0x200U) == 0) { @@ -3824,8 +3824,8 @@ void GetSmokeDrift(VECTOR *Wind) } Wind->vy = 0; - Wind->vx = FIXED(WindMagnitude * CosX); - Wind->vz = FIXED(-WindMagnitude * SinX); + Wind->vx = FIXEDH(WindMagnitude * CosX); + Wind->vz = FIXEDH(-WindMagnitude * SinX); } @@ -5583,7 +5583,7 @@ void DisplaySplashes(void) if (0x1e < gRainCount >> 2) uVar3 = 0x1e; - iVar4 = FIXED(uVar3 * FrAng * 3); + iVar4 = FIXEDH(uVar3 * FrAng * 3); gte_SetRotMatrix(&aspect); // [A] norot @@ -5612,9 +5612,9 @@ void DisplaySplashes(void) uVar2 = uVar3 >> 4 & 0xfff; rand = uVar3 * 0x19660d + 0x3c6ef35f; uVar3 = rand >> 0xe & 0xfff; - Position.vx = FIXED(Gnd1.vx * uVar2 + Gnd2.vx * uVar3); - Position.vy = FIXED(Gnd1.vy * uVar2 + Gnd2.vy * uVar3) + CamGnd.vy; - Position.vz = FIXED(Gnd1.vz * uVar2 + Gnd2.vz * uVar3); + Position.vx = FIXEDH(Gnd1.vx * uVar2 + Gnd2.vx * uVar3); + Position.vy = FIXEDH(Gnd1.vy * uVar2 + Gnd2.vy * uVar3) + CamGnd.vy; + Position.vz = FIXEDH(Gnd1.vz * uVar2 + Gnd2.vz * uVar3); ShowLight(&Position, &col, 12, &drop_texture); } diff --git a/src_rebuild/GAME/C/DENTING.C b/src_rebuild/GAME/C/DENTING.C index 9b565e2e..563e4a9f 100644 --- a/src_rebuild/GAME/C/DENTING.C +++ b/src_rebuild/GAME/C/DENTING.C @@ -163,9 +163,9 @@ void DentCar(_CAR_DATA *cp) VertNo = 0; while (VertNo < pCleanModel->num_vertices) { - gTempCarVertDump[cp->id][VertNo].vx = CleanVertPtr->vx + FIXED((DamVertPtr->vx - CleanVertPtr->vx) * tempDamage[VertNo] / 2); - gTempCarVertDump[cp->id][VertNo].vy = CleanVertPtr->vy + FIXED((DamVertPtr->vy - CleanVertPtr->vy) * tempDamage[VertNo] / 2); - gTempCarVertDump[cp->id][VertNo].vz = CleanVertPtr->vz + FIXED((DamVertPtr->vz - CleanVertPtr->vz) * tempDamage[VertNo] / 2); + gTempCarVertDump[cp->id][VertNo].vx = CleanVertPtr->vx + FIXEDH((DamVertPtr->vx - CleanVertPtr->vx) * tempDamage[VertNo] / 2); + gTempCarVertDump[cp->id][VertNo].vy = CleanVertPtr->vy + FIXEDH((DamVertPtr->vy - CleanVertPtr->vy) * tempDamage[VertNo] / 2); + gTempCarVertDump[cp->id][VertNo].vz = CleanVertPtr->vz + FIXEDH((DamVertPtr->vz - CleanVertPtr->vz) * tempDamage[VertNo] / 2); DamVertPtr++; CleanVertPtr++; @@ -483,9 +483,9 @@ void LoseHubcap(int car, int Hubcap, int Velocity) } gHubcap.Duration = 100; - gHubcap.Direction.vx = FIXED(FIXED(cp->st.n.angularVelocity[1]) * gHubcap.Offset[Hubcap].vz) + FIXED(cp->st.n.linearVelocity[0]); - gHubcap.Direction.vy = FIXED(cp->st.n.linearVelocity[1]); - gHubcap.Direction.vz = FIXED(-FIXED(cp->st.n.angularVelocity[1]) * gHubcap.Offset[Hubcap].vx) + FIXED(cp->st.n.linearVelocity[2]); + gHubcap.Direction.vx = FIXEDH(FIXEDH(cp->st.n.angularVelocity[1]) * gHubcap.Offset[Hubcap].vz) + FIXEDH(cp->st.n.linearVelocity[0]); + gHubcap.Direction.vy = FIXEDH(cp->st.n.linearVelocity[1]); + gHubcap.Direction.vz = FIXEDH(-FIXEDH(cp->st.n.angularVelocity[1]) * gHubcap.Offset[Hubcap].vx) + FIXEDH(cp->st.n.linearVelocity[2]); } } } diff --git a/src_rebuild/GAME/C/DRAW.C b/src_rebuild/GAME/C/DRAW.C index e048359d..9b8786a6 100644 --- a/src_rebuild/GAME/C/DRAW.C +++ b/src_rebuild/GAME/C/DRAW.C @@ -354,9 +354,9 @@ void DrawSprites(int numFound) int local_38; int local_2c; - z = FIXED(camera_matrix.m[2][0] * day_vectors[GameLevel].vx) + - FIXED(camera_matrix.m[2][1] * day_vectors[GameLevel].vy) + - FIXED(camera_matrix.m[2][2] * day_vectors[GameLevel].vz) + 0x1000 * 0xc00; + z = FIXEDH(camera_matrix.m[2][0] * day_vectors[GameLevel].vx) + + FIXEDH(camera_matrix.m[2][1] * day_vectors[GameLevel].vy) + + FIXEDH(camera_matrix.m[2][2] * day_vectors[GameLevel].vz) + 0x1000 * 0xc00; lightLevel = (z >> 0x12) + 0x20U & 0xff; diff --git a/src_rebuild/GAME/C/DRIVINGGAMES.C b/src_rebuild/GAME/C/DRIVINGGAMES.C index f36d24ce..cb9c7881 100644 --- a/src_rebuild/GAME/C/DRIVINGGAMES.C +++ b/src_rebuild/GAME/C/DRIVINGGAMES.C @@ -994,13 +994,13 @@ void GetConePos(int cone, VECTOR *pos, int side) if (side == 0) { - pos->vx = pTVar2->x - FIXED(iVar6); + pos->vx = pTVar2->x - FIXEDH(iVar6); pos->vy = pTVar2->y; iVar4 = -iVar4; } else { - pos->vx = pTVar2->x + FIXED(iVar6); + pos->vx = pTVar2->x + FIXEDH(iVar6); pos->vy = pTVar2->y; } diff --git a/src_rebuild/GAME/C/EVENT.C b/src_rebuild/GAME/C/EVENT.C index 4d05e683..e175686b 100644 --- a/src_rebuild/GAME/C/EVENT.C +++ b/src_rebuild/GAME/C/EVENT.C @@ -2152,7 +2152,7 @@ void StepFromToEvent(_EVENT *ev) iVar4 = (*ev->data + -1) * (int)*(short*)((int)rcossin_tbl + ((uVar3 - (uVar3 >> 0x1f)) * 2 & 0x3ffc)); } - uVar3 = FIXED(iVar4) + 1U ^ uVar2; + uVar3 = FIXEDH(iVar4) + 1U ^ uVar2; LAB_00047b78: *local_t0_132 = iVar6 + (uVar3 - uVar2); @@ -2480,7 +2480,7 @@ void StepPathEvent(_EVENT *ev) { speed = ev->data[1] * (0x1000 - CameraCnt) + ev->data[2] * CameraCnt; - speed = FIXED(speed); + speed = FIXEDH(speed); } else { @@ -2507,7 +2507,7 @@ void StepPathEvent(_EVENT *ev) speed = (iVar9 >> 0x1f ^ 5U) - (iVar9 >> 0x1f); } - speed = speed + FIXED(iVar4); + speed = speed + FIXEDH(iVar4); } LAB_00048238: iVar4 = *curr + speed * iVar13; @@ -3484,9 +3484,9 @@ void DrawFerrisWheel(MATRIX *matrix, VECTOR *pos) cx = (int)rcossin_tbl[angle * 2]; sx = (int)rcossin_tbl[angle * 2 + 1]; - offset.vx = FIXED(spoke[0].vx * cx + spoke[1].vx * sx); - offset.vy = FIXED(spoke[0].vy * cx + spoke[1].vy * sx); - offset.vz = FIXED(spoke[0].vz * cx + spoke[1].vz * sx); + offset.vx = FIXEDH(spoke[0].vx * cx + spoke[1].vx * sx); + offset.vy = FIXEDH(spoke[0].vy * cx + spoke[1].vy * sx); + offset.vz = FIXEDH(spoke[0].vz * cx + spoke[1].vz * sx); carPos.vx = pos->vx + offset.vx; carPos.vy = pos->vy + offset.vy; @@ -3978,7 +3978,7 @@ void DrawEvents(int camera) _RotMatrixY(&matrix, ev->rotation); pos.vx = pos.vx - boatOffset.vx; pos.vz = pos.vz - boatOffset.vz; - pos.vy = (pos.vy - boatOffset.vy) + FIXED((int)ev->node * (int)rcossin_tbl[(*ev->data & 0xfffU) * 2]); + pos.vy = (pos.vy - boatOffset.vy) + FIXEDH((int)ev->node * (int)rcossin_tbl[(*ev->data & 0xfffU) * 2]); } else if (uVar3 != 0xc0) { @@ -4395,7 +4395,7 @@ _sdPlane* EventSurface(VECTOR *pos, _sdPlane *plane) return &sea; } - uVar6 = (iVar8 - (FIXED(iVar5 * 3328) + ev->data[2] + ev->position.vy)) + (FIXED(iVar7) * rcossin_tbl[uVar3 * 2]) / iVar9; + uVar6 = (iVar8 - (FIXEDH(iVar5 * 3328) + ev->data[2] + ev->position.vy)) + (FIXEDH(iVar7) * rcossin_tbl[uVar3 * 2]) / iVar9; iVar5 = rcossin_tbl[uVar3 * 2]; goto LAB_0004a9f8; } diff --git a/src_rebuild/GAME/C/FELONY.C b/src_rebuild/GAME/C/FELONY.C index 5b014b96..e3cd0c61 100644 --- a/src_rebuild/GAME/C/FELONY.C +++ b/src_rebuild/GAME/C/FELONY.C @@ -650,7 +650,7 @@ void CheckPlayerMiscFelonies(void) st = GET_STRAIGHT(surfInd); // Driver2StraightsPtr + surfInd; uVar6 = st->angle & 0xfff; uVar4 = st->NumLanes & 0xf; - uVar6 = uVar4 - (FIXED((carPos->vx - st->Midx) * rcossin_tbl[uVar6 * 2 + 1] - (carPos->vz - st->Midz) * rcossin_tbl[uVar6 * 2]) + 0x200 >> 9); + uVar6 = uVar4 - (FIXEDH((carPos->vx - st->Midx) * rcossin_tbl[uVar6 * 2 + 1] - (carPos->vz - st->Midz) * rcossin_tbl[uVar6 * 2]) + 0x200 >> 9); iVar5 = uVar4 * 2; if (uVar6 < 0) @@ -753,7 +753,7 @@ void CheckPlayerMiscFelonies(void) else limit = (maxSpeed * 3) >> 1; - if (FIXED(cp->hd.wheel_speed) > limit) + if (FIXEDH(cp->hd.wheel_speed) > limit) NoteFelony(&felonyData, 2, 0x1000); } diff --git a/src_rebuild/GAME/C/HANDLING.C b/src_rebuild/GAME/C/HANDLING.C index 634e94a3..f36298b6 100644 --- a/src_rebuild/GAME/C/HANDLING.C +++ b/src_rebuild/GAME/C/HANDLING.C @@ -82,9 +82,9 @@ void InitCarPhysics(_CAR_DATA *cp, long(*startpos)[4], int direction) cp->hd.autoBrake = 0; - cp->st.n.orientation[0] = FIXED(-rcossin_tbl[(direction & 0xffeU) + 1] * iVar2); + cp->st.n.orientation[0] = FIXEDH(-rcossin_tbl[(direction & 0xffeU) + 1] * iVar2); cp->st.n.orientation[1] = rcossin_tbl[direction & 0xffeU]; - cp->st.n.orientation[2] = FIXED(rcossin_tbl[direction & 0xffeU] * iVar2); + cp->st.n.orientation[2] = FIXEDH(rcossin_tbl[direction & 0xffeU] * iVar2); cp->st.n.orientation[3] = rcossin_tbl[(direction & 0xffeU) + 1]; cp->st.n.fposition[0] = (*startpos)[0] << 4; @@ -117,7 +117,7 @@ void InitCarPhysics(_CAR_DATA *cp, long(*startpos)[4], int direction) cp->hd.drawCarMat.m[2][1] = ~cp->hd.where.m[2][1]; cp->hd.drawCarMat.m[2][2] = cp->hd.where.m[2][2] ^ 0xFFFF; - cVar3 = (iVar5 >> 5); + cVar3 = FixFloorSigned(iVar5, 5); cVar1 = 14 - cVar3; cVar3 = cVar3 + 14; @@ -182,9 +182,9 @@ void TempBuildHandlingMatrix(_CAR_DATA *cp, int init) } uVar3 = cp->hd.direction & 0xffe; - cp->st.n.orientation[0] = FIXED(-rcossin_tbl[uVar3 + 1] * iVar1); + cp->st.n.orientation[0] = FIXEDH(-rcossin_tbl[uVar3 + 1] * iVar1); cp->st.n.orientation[1] = rcossin_tbl[uVar3]; - cp->st.n.orientation[2] = FIXED(rcossin_tbl[uVar3] * iVar1); + cp->st.n.orientation[2] = FIXEDH(rcossin_tbl[uVar3] * iVar1); cp->st.n.orientation[3] = rcossin_tbl[uVar3 + 1]; RebuildCarMatrix(&cp->st, cp); @@ -719,7 +719,7 @@ void GlobalTimeStep(void) cp->hd.aacc[2] = 0; if (200000 < st->n.linearVelocity[1]) // reduce vertical velocity - st->n.linearVelocity[1] = st->n.linearVelocity[1] * 3 >> 2; + st->n.linearVelocity[1] = FixFloorSigned(st->n.linearVelocity[1] * 3, 2); if (cp->hd.speed == 0) { @@ -784,10 +784,10 @@ void GlobalTimeStep(void) delta_orientation[2] = (-orient[0] * AV[1] + orient[1] * AV[0] + orient[3] * AV[2]); delta_orientation[3] = (-orient[0] * AV[0] - orient[1] * AV[1]) - orient[2] * AV[2]; - orient[0] += FIXED(delta_orientation[0]); - orient[1] += FIXED(delta_orientation[1]); - orient[2] += FIXED(delta_orientation[2]); - orient[3] += FIXED(delta_orientation[3]); + orient[0] += FIXEDH(delta_orientation[0]); + orient[1] += FIXEDH(delta_orientation[1]); + orient[2] += FIXEDH(delta_orientation[2]); + orient[3] += FIXEDH(delta_orientation[3]); RebuildCarMatrix((RigidBodyState*)st, cp); } @@ -845,10 +845,10 @@ void GlobalTimeStep(void) AV[1] = FixHalfRound(st->n.angularVelocity[1], 13); AV[2] = FixHalfRound(st->n.angularVelocity[2], 13); - local_a3_1288->n.orientation[0] = FIXED(-orient[1] * AV[2] + orient[2] * AV[1] + orient[3] * AV[0]); - local_a3_1288->n.orientation[1] = FIXED((orient[0] * AV[2] - orient[2] * AV[0]) + orient[3] * AV[1]); - local_a3_1288->n.orientation[2] = FIXED(-orient[0] * AV[1] + orient[1] * AV[0] + orient[3] * AV[2]); - local_a3_1288->n.orientation[3] = FIXED((-orient[0] * AV[0] - orient[1] * AV[1]) - orient[2] * AV[2]); + local_a3_1288->n.orientation[0] = FIXEDH(-orient[1] * AV[2] + orient[2] * AV[1] + orient[3] * AV[0]); + local_a3_1288->n.orientation[1] = FIXEDH((orient[0] * AV[2] - orient[2] * AV[0]) + orient[3] * AV[1]); + local_a3_1288->n.orientation[2] = FIXEDH(-orient[0] * AV[1] + orient[1] * AV[0] + orient[3] * AV[2]); + local_a3_1288->n.orientation[3] = FIXEDH((-orient[0] * AV[0] - orient[1] * AV[1]) - orient[2] * AV[2]); local_a3_1288->n.linearVelocity[0] = 0; local_a3_1288->n.linearVelocity[1] = 0; @@ -903,14 +903,14 @@ void GlobalTimeStep(void) lever1[1] = iVar9 + iVar28; iVar28 = depth * 0xc000; - howHard = (FIXED(st->n.angularVelocity[1] * lever0[2] - st->n.angularVelocity[2] * lever0[1]) + st->n.linearVelocity[0]) - - (FIXED(p_Var25->n.angularVelocity[1] * lever1[2] - p_Var25->n.angularVelocity[2] * lever1[1]) + p_Var25->n.linearVelocity[0]); + howHard = (FIXEDH(st->n.angularVelocity[1] * lever0[2] - st->n.angularVelocity[2] * lever0[1]) + st->n.linearVelocity[0]) - + (FIXEDH(p_Var25->n.angularVelocity[1] * lever1[2] - p_Var25->n.angularVelocity[2] * lever1[1]) + p_Var25->n.linearVelocity[0]); - iVar19 = (FIXED(st->n.angularVelocity[2] * lever0[0] - st->n.angularVelocity[0] * lever0[2]) + st->n.linearVelocity[1]) - - (FIXED(p_Var25->n.angularVelocity[2] * lever1[0] - p_Var25->n.angularVelocity[0] * lever1[2]) + p_Var25->n.linearVelocity[1]); + iVar19 = (FIXEDH(st->n.angularVelocity[2] * lever0[0] - st->n.angularVelocity[0] * lever0[2]) + st->n.linearVelocity[1]) - + (FIXEDH(p_Var25->n.angularVelocity[2] * lever1[0] - p_Var25->n.angularVelocity[0] * lever1[2]) + p_Var25->n.linearVelocity[1]); - iVar9 = (FIXED(st->n.angularVelocity[0] * lever0[1] - st->n.angularVelocity[1] * lever0[0]) + st->n.linearVelocity[2]) - - (FIXED(p_Var25->n.angularVelocity[0] * lever1[1] - p_Var25->n.angularVelocity[1] * lever1[0]) +p_Var25->n.linearVelocity[2]); + iVar9 = (FIXEDH(st->n.angularVelocity[0] * lever0[1] - st->n.angularVelocity[1] * lever0[0]) + st->n.linearVelocity[2]) - + (FIXEDH(p_Var25->n.angularVelocity[0] * lever1[1] - p_Var25->n.angularVelocity[1] * lever1[0]) +p_Var25->n.linearVelocity[2]); lVar10 = normal[0]; lVar7 = normal[1]; @@ -953,8 +953,8 @@ void GlobalTimeStep(void) if (0x1b00 < howHard) { velocity.vy = -0x11; - velocity.vx = (cp->st.n.linearVelocity[0]) >> 0xc; - velocity.vz = (cp->st.n.linearVelocity[2]) >> 0xc; + velocity.vx = FIXED(cp->st.n.linearVelocity[0]); + velocity.vz = FIXED(cp->st.n.linearVelocity[2]); collisionpoint[1] = -collisionpoint[1]; @@ -1019,7 +1019,7 @@ void GlobalTimeStep(void) } } - iVar19 = FIXED(iVar19) * iVar24 >> 3; + iVar19 = FIXEDH(iVar19) * iVar24 >> 3; velocity.vx = (normal[0] >> 3) * iVar19 >> 6; velocity.vz = (normal[2] >> 3) * iVar19 >> 6; velocity.vy = (normal[1] >> 3) * iVar19 >> 6; @@ -1032,9 +1032,9 @@ void GlobalTimeStep(void) iVar19 = car_cosmetics[cp->ap.model].twistRateY / 2; - torque[0] = FIXED(velocity.vy * lever0[2] - velocity.vz * lever0[1]) * iVar19; - torque[1] = FIXED(velocity.vz * lever0[0] - velocity.vx * lever0[2]) * iVar19; - torque[2] = FIXED(velocity.vx * lever0[1] - velocity.vy * lever0[0]) * iVar19; + torque[0] = FIXEDH(velocity.vy * lever0[2] - velocity.vz * lever0[1]) * iVar19; + torque[1] = FIXEDH(velocity.vz * lever0[0] - velocity.vx * lever0[2]) * iVar19; + torque[2] = FIXEDH(velocity.vx * lever0[1] - velocity.vy * lever0[0]) * iVar19; if (c1->controlType == 4) { @@ -1056,16 +1056,16 @@ void GlobalTimeStep(void) if (c1->controlType == 4 && cp->hndType != 0) { iVar9 = iVar28 * 5; - iVar28 = iVar9 >> 3; + iVar28 = FixFloorSigned(iVar9, 3); } } else { iVar9 = iVar28 * (7 - gCopDifficultyLevel); - iVar28 = iVar9 >> 3; + iVar28 = FixFloorSigned(iVar9, 3); } - iVar28 = FIXED(iVar28) * iVar21 >> 3; + iVar28 = FIXEDH(iVar28) * iVar21 >> 3; velocity.vx = (normal[0] >> 3) * iVar28 >> 6; velocity.vy = (normal[1] >> 3) * iVar28 >> 6; velocity.vz = (normal[2] >> 3) * iVar28 >> 6; @@ -1075,9 +1075,9 @@ void GlobalTimeStep(void) p_Var27->n.linearVelocity[2] = p_Var27->n.linearVelocity[2] + velocity.vz; iVar28 = car_cosmetics[c1->ap.model].twistRateY / 2; - torque[0] = FIXED(lever1[1] * velocity.vz - lever1[2] * velocity.vy) * iVar28; - torque[1] = FIXED(lever1[2] * velocity.vx - lever1[0] * velocity.vz) * iVar28; - torque[2] = FIXED(lever1[0] * velocity.vy - lever1[1] * velocity.vx) * iVar28; + torque[0] = FIXEDH(lever1[1] * velocity.vz - lever1[2] * velocity.vy) * iVar28; + torque[1] = FIXEDH(lever1[2] * velocity.vx - lever1[0] * velocity.vz) * iVar28; + torque[2] = FIXEDH(lever1[0] * velocity.vy - lever1[1] * velocity.vx) * iVar28; if (c1->controlType == 4) { @@ -1357,28 +1357,28 @@ void LongQuaternion2Matrix(long(*qua)[4], MATRIX *m) iVar8 = (*qua)[2]; iVar7 = (*qua)[3]; - sVar1 = (iVar5 * iVar5) + 0x400 >> 0xb; - sVar2 = (iVar8 * iVar8) + 0x400 >> 0xb; - sVar3 = (iVar6 * iVar6) + 0x400 >> 0xb; + sVar1 = FixHalfRound(iVar5 * iVar5, 11); + sVar2 = FixHalfRound(iVar8 * iVar8, 11); + sVar3 = FixHalfRound(iVar6 * iVar6, 11); m->m[0][0] = 4096 - (sVar1 + sVar2); m->m[1][1] = 4096 - (sVar3 + sVar2); m->m[2][2] = 4096 - (sVar3 + sVar1); - sVar2 = (iVar8 * iVar7) + 0x400 >> 0xb; - sVar1 = (iVar6 * iVar5) + 0x400 >> 0xb; + sVar2 = FixHalfRound(iVar8 * iVar7, 11); + sVar1 = FixHalfRound(iVar6 * iVar5, 11); m->m[0][1] = sVar1 - sVar2; - sVar3 = (iVar6 * iVar8) + 0x400 >> 0xb; - sVar4 = (iVar5 * iVar7) + 0x400 >> 0xb; + sVar3 = FixHalfRound(iVar6 * iVar8, 11); + sVar4 = FixHalfRound(iVar5 * iVar7, 11); m->m[0][2] = sVar3 + sVar4; m->m[1][0] = sVar1 + sVar2; m->m[2][0] = sVar3 - sVar4; - sVar2 = (iVar6 * iVar7) + 0x400 >> 0xb; - sVar1 = (iVar5 * iVar8) + 0x400 >> 0xb; + sVar2 = FixHalfRound(iVar6 * iVar7, 11); + sVar1 = FixHalfRound(iVar5 * iVar8, 11); m->m[1][2] = sVar1 - sVar2; m->m[2][1] = sVar1 + sVar2; @@ -1441,7 +1441,7 @@ void initOBox(_CAR_DATA *cp) { iVar3 = cp->ap.carCos->colBox.vx * 14; - sVar2 = (iVar3 >> 4); + sVar2 = FixFloorSigned(iVar3, 4); cp->hd.oBox.length[0] = sVar2; } else @@ -1540,11 +1540,11 @@ void RebuildCarMatrix(RigidBodyState *st, _CAR_DATA *cp) { sm = 6144 - (osm >> 13); - st->n.orientation[0] = FIXED(sm * iVar6); - st->n.orientation[1] = FIXED(sm * iVar5); - st->n.orientation[2] = FIXED(sm * iVar4); + st->n.orientation[0] = FIXEDH(sm * iVar6); + st->n.orientation[1] = FIXEDH(sm * iVar5); + st->n.orientation[2] = FIXEDH(sm * iVar4); - sm = FIXED(sm * iVar3); + sm = FIXEDH(sm * iVar3); } st->n.orientation[3] = sm; @@ -1749,31 +1749,31 @@ void CheckCarToCarCollisions(void) iVar6 = colBox->vy; iVar2 = colBox->vz * 9; - iVar9 = cp->hd.where.m[0][2] * (iVar2 >> 3); + iVar9 = cp->hd.where.m[0][2] * FixFloorSigned(iVar2, 3); iVar4 = colBox->vx * 9; if (iVar9 < 0) iVar9 = -iVar9; - iVar10 = cp->hd.where.m[0][0] * (iVar4 >> 3); + iVar10 = cp->hd.where.m[0][0] * FixFloorSigned(iVar4, 3); if (iVar10 < 0) iVar10 = -iVar10; - iVar9 = FIXED(iVar9 + iVar10) + iVar6; - iVar2 = cp->hd.where.m[2][2] * (iVar2 >> 3); + iVar9 = FIXEDH(iVar9 + iVar10) + iVar6; + iVar2 = cp->hd.where.m[2][2] * FixFloorSigned(iVar2, 3); if (iVar2 < 0) iVar2 = -iVar2; - iVar4 = cp->hd.where.m[2][0] * (iVar4 >> 3); + iVar4 = cp->hd.where.m[2][0] * FixFloorSigned(iVar4, 3); iVar10 = cp->hd.where.t[0]; iVar5 = iVar10 - iVar9; if (iVar4 < 0) iVar4 = -iVar4; - iVar6 = FIXED(iVar2 + iVar4) + iVar6; + iVar6 = FIXEDH(iVar2 + iVar4) + iVar6; iVar4 = cp->hd.where.t[2]; iVar2 = iVar4 - iVar6; @@ -1790,26 +1790,26 @@ void CheckCarToCarCollisions(void) if (iVar2 < 0) { - iVar2 = FIXED(iVar2); - bb2->x0 = (iVar5 >> 4) + (iVar2 >> 3); + iVar2 = FIXEDH(iVar2); + bb2->x0 = FixFloorSigned(iVar5, 4) + FixFloorSigned(iVar2, 3); } else { - iVar2 = FIXED(iVar2); - bb2->x1 = (iVar10 >> 4) + (iVar2 >> 3); + iVar2 = FIXEDH(iVar2); + bb2->x1 = FixFloorSigned(iVar10, 4) + FixFloorSigned(iVar2, 3); } iVar2 = cp->st.n.linearVelocity[2]; if (iVar2 < 0) { - iVar2 = FIXED(iVar2); - bb2->z0 = bb2->z0 + (iVar2 >> 3); + iVar2 = FIXEDH(iVar2); + bb2->z0 = bb2->z0 + FixFloorSigned(iVar2, 3); } else { - iVar2 = FIXED(iVar2); - bb2->z1 = bb2->z1 + (iVar2 >> 3); + iVar2 = FIXEDH(iVar2); + bb2->z1 = bb2->z1 + FixFloorSigned(iVar2, 3); } iVar6 = cp->hd.where.t[1]; @@ -2212,20 +2212,20 @@ void ProcessCarPad(_CAR_DATA *cp, ulong pad, char PadSteer, char use_analogue) if ((pad & 0x80) != 0) { iVar3 = cp->hd.wheel_speed * 1500; - iVar3 = FIXED(iVar3 >> 10); + iVar3 = FIXEDH(FixFloorSigned(iVar3, 10)); if (-iVar3 < 0x17) sVar2 = -5000; else - sVar2 = ((iVar3 + 0x116) * -0x12aa) >> 8; + sVar2 = ((iVar3 + 278) * -4778) >> 8; cp->thrust = sVar2; - cp->thrust = FIXED(cp->thrust * cp->ap.carCos->powerRatio); + cp->thrust = FIXEDH(cp->thrust * cp->ap.carCos->powerRatio); } else if ((pad & 0x40) != 0) { cp->thrust = 0x1333; - cp->thrust = FIXED(cp->ap.carCos->powerRatio * 0x1333); + cp->thrust = FIXEDH(cp->ap.carCos->powerRatio * 0x1333); if (cp->hndType == 5) { @@ -2264,7 +2264,7 @@ void ProcessCarPad(_CAR_DATA *cp, ulong pad, char PadSteer, char use_analogue) if (iVar3 != -1) { if (3050 < cp->ap.carCos->powerRatio) - cp->thrust = FIXED(car_data[iVar3].ap.carCos->powerRatio * 0x1333); + cp->thrust = FIXEDH(car_data[iVar3].ap.carCos->powerRatio * 0x1333); iVar7 = cp->hd.where.t[0] - car_data[iVar3].hd.where.t[0] >> 10; iVar3 = cp->hd.where.t[2] - car_data[iVar3].hd.where.t[2] >> 10; diff --git a/src_rebuild/GAME/C/JOB_FX.C b/src_rebuild/GAME/C/JOB_FX.C index 9bbfc3fb..3757ce03 100644 --- a/src_rebuild/GAME/C/JOB_FX.C +++ b/src_rebuild/GAME/C/JOB_FX.C @@ -349,11 +349,11 @@ void initExplosion(void) pSVar4->vy = 5; pSVar4[1].vy = -0x109; - pSVar4->vx = FIXED(rcossin_tbl[(uVar9 & 0xf) * 0x200 + 1] * 0x200); - pSVar4->vz = FIXED(rcossin_tbl[(uVar9 & 0xf) * 0x200] * 0x200); + pSVar4->vx = FIXEDH(rcossin_tbl[(uVar9 & 0xf) * 0x200 + 1] * 0x200); + pSVar4->vz = FIXEDH(rcossin_tbl[(uVar9 & 0xf) * 0x200] * 0x200); - pSVar4[1].vx = FIXED(rcossin_tbl[uVar3 * 2 + 1] * 0x1ea); - pSVar4[1].vz = FIXED(rcossin_tbl[uVar3 * 2] * 0x1ea); + pSVar4[1].vx = FIXEDH(rcossin_tbl[uVar3 * 2 + 1] * 0x1ea); + pSVar4[1].vz = FIXEDH(rcossin_tbl[uVar3 * 2] * 0x1ea); pSVar4 = pSVar4 + 2; uVar9 = uVar5; @@ -373,11 +373,11 @@ void initExplosion(void) pSVar4->vy = -0x109; pSVar4[1].vy = -0x1f9; - pSVar4->vx = FIXED(rcossin_tbl[uVar7 * 2 + 1] * 0x1ea); - pSVar4->vz = FIXED(rcossin_tbl[uVar7 * 2] * 0x1ea); + pSVar4->vx = FIXEDH(rcossin_tbl[uVar7 * 2 + 1] * 0x1ea); + pSVar4->vz = FIXEDH(rcossin_tbl[uVar7 * 2] * 0x1ea); - pSVar4[1].vx = FIXED(rcossin_tbl[uVar3 * 2 + 1] * 0x14a); - pSVar4[1].vz = FIXED(rcossin_tbl[uVar3 * 2] * 0x14a); + pSVar4[1].vx = FIXEDH(rcossin_tbl[uVar3 * 2 + 1] * 0x14a); + pSVar4[1].vz = FIXEDH(rcossin_tbl[uVar3 * 2] * 0x14a); pSVar4 = pSVar4 + 2; } while (-1 < iVar6); @@ -396,11 +396,11 @@ void initExplosion(void) pSVar4->vy = -0x1f9; pSVar4[1].vy = -0x269; - pSVar4->vx = FIXED(rcossin_tbl[uVar7 * 2 + 1] * 0x14a); - pSVar4->vz = FIXED(rcossin_tbl[uVar7 * 2] * 0x14a); + pSVar4->vx = FIXEDH(rcossin_tbl[uVar7 * 2 + 1] * 0x14a); + pSVar4->vz = FIXEDH(rcossin_tbl[uVar7 * 2] * 0x14a); - pSVar4[1].vx = FIXED(rcossin_tbl[uVar3 * 2 + 1] * 100); - pSVar4[1].vz = FIXED(rcossin_tbl[uVar3 * 2] * 100); + pSVar4[1].vx = FIXEDH(rcossin_tbl[uVar3 * 2 + 1] * 100); + pSVar4[1].vz = FIXEDH(rcossin_tbl[uVar3 * 2] * 100); pSVar4 = pSVar4 + 2; } while (-1 < iVar6); diff --git a/src_rebuild/GAME/C/LEADAI.C b/src_rebuild/GAME/C/LEADAI.C index 9417069d..dd0db29e 100644 --- a/src_rebuild/GAME/C/LEADAI.C +++ b/src_rebuild/GAME/C/LEADAI.C @@ -308,7 +308,7 @@ void LeadUpdateState(_CAR_DATA *cp) if (iVar2 < 0) iVar2 = -iVar2; - iVar3 = FIXED(cp->st.n.angularVelocity[1]); + iVar3 = FIXEDH(cp->st.n.angularVelocity[1]); if (0 < iVar2) cp->ai.l.dstate = 5; @@ -394,7 +394,7 @@ void LeadUpdateState(_CAR_DATA *cp) uVar4 = uVar7 & 0xfff; iVar3 = cp->hd.speed; iVar2 = ((uVar7 - (int)cp->ai.l.targetDir) + 0x800 & 0xfff) - 0x800; - iVar5 = FIXED((cp->ai.l.targetX - cp->hd.where.t[0]) * (int)rcossin_tbl[uVar4 * 2] + (cp->ai.l.targetZ - cp->hd.where.t[2]) * (int)rcossin_tbl[uVar4 * 2 + 1]); + iVar5 = FIXEDH((cp->ai.l.targetX - cp->hd.where.t[0]) * (int)rcossin_tbl[uVar4 * 2] + (cp->ai.l.targetZ - cp->hd.where.t[2]) * (int)rcossin_tbl[uVar4 * 2 + 1]); if (100 < iVar3) { LAB_LEAD__000e7824: @@ -563,7 +563,7 @@ ulong LeadPadResponse(_CAR_DATA *cp) t0 = 0; deltaTh = ((cp->hd.direction - cp->ai.l.targetDir) + 0x800U & 0xfff) - 0x800; - avel = FIXED(cp->st.n.angularVelocity[1]); + avel = FIXEDH(cp->st.n.angularVelocity[1]); switch (cp->ai.l.dstate) { case 0: @@ -603,7 +603,7 @@ ulong LeadPadResponse(_CAR_DATA *cp) case 3: uVar4 = cp->ai.l.targetDir & 0xfff; - iVar2 = FIXED(-rcossin_tbl[uVar4 * 2 + 1] * ((cp->hd).where.t[0] - cp->ai.l.targetX) + rcossin_tbl[uVar4 * 2] * ((cp->hd).where.t[2] - cp->ai.l.targetZ)); + iVar2 = FIXEDH(-rcossin_tbl[uVar4 * 2 + 1] * ((cp->hd).where.t[0] - cp->ai.l.targetX) + rcossin_tbl[uVar4 * 2] * ((cp->hd).where.t[2] - cp->ai.l.targetZ)); iVar3 = pathParams[4]; if ((pathParams[4] < iVar2) || (iVar3 = -pathParams[4], iVar2 < -pathParams[4])) @@ -611,7 +611,7 @@ ulong LeadPadResponse(_CAR_DATA *cp) iVar2 = iVar3; } - steerDelta = FIXED(pathParams[0] * FIXED(-rcossin_tbl[uVar4 * 2 + 1] * FIXED((cp->st).n.linearVelocity[0]) + rcossin_tbl[uVar4 * 2] * FIXED((cp->st).n.linearVelocity[2])) + pathParams[1] * avel + pathParams[2] * iVar2 + pathParams[3] * deltaTh) - cp->wheel_angle; + steerDelta = FIXEDH(pathParams[0] * FIXEDH(-rcossin_tbl[uVar4 * 2 + 1] * FIXEDH((cp->st).n.linearVelocity[0]) + rcossin_tbl[uVar4 * 2] * FIXEDH((cp->st).n.linearVelocity[2])) + pathParams[1] * avel + pathParams[2] * iVar2 + pathParams[3] * deltaTh) - cp->wheel_angle; t0 = 0x40; @@ -931,18 +931,15 @@ void FakeMotion(_CAR_DATA *cp) c = rcossin_tbl[(angle & 0xfffU) * 2]; s = rcossin_tbl[(angle & 0xfffU) * 2 + 1]; - d = FIXED(c * (iVar10 - iVar7) + s * (iVar8 - iVar5)); + d = FIXEDH(c * (iVar10 - iVar7) + s * (iVar8 - iVar5)); toGo = (straight->length >> 1) - d; if (-1 < toGo) { d = d + 0x78; - (cp->hd).where.t[0] = FIXED(c * d) + straight->Midx; - (cp->hd).where.t[2] = FIXED(s * d) + straight->Midz; - - cp->st.n.fposition[0] = cp->hd.where.t[0] << 4; - cp->st.n.fposition[2] = cp->hd.where.t[2] << 4; + (cp->hd).where.t[0] = FIXEDH(c * d) + straight->Midx; + (cp->hd).where.t[2] = FIXEDH(s * d) + straight->Midz; return; } @@ -979,12 +976,12 @@ void FakeMotion(_CAR_DATA *cp) uVar9 = lVar3 + 0x13193 / iVar7; uVar6 = uVar9 & 0xfff; sVar1 = rcossin_tbl[uVar6 * 2 + 1]; - (cp->hd).where.t[0] = FIXED(rcossin_tbl[uVar6 * 2] * iVar7) + curve->Midx; + (cp->hd).where.t[0] = FIXEDH(rcossin_tbl[uVar6 * 2] * iVar7) + curve->Midx; iVar5 = curve->Midz; uVar4 = (short)uVar9 + 0x400; LAB_LEAD__000e82cc: cp->ai.l.targetDir = uVar4 & 0xfff; - (cp->hd).where.t[2] = FIXED(sVar1 * iVar7) + iVar5; + (cp->hd).where.t[2] = FIXEDH(sVar1 * iVar7) + iVar5; cp->st.n.fposition[0] = cp->hd.where.t[0] << 4; cp->st.n.fposition[2] = cp->hd.where.t[2] << 4; @@ -1016,7 +1013,7 @@ void FakeMotion(_CAR_DATA *cp) uVar9 = lVar3 - 0x13193 / iVar7; uVar6 = uVar9 & 0xfff; sVar1 = rcossin_tbl[uVar6 * 2 + 1]; - (cp->hd).where.t[0] = FIXED(rcossin_tbl[uVar6 * 2] * iVar7) + curve->Midx; + (cp->hd).where.t[0] = FIXEDH(rcossin_tbl[uVar6 * 2] * iVar7) + curve->Midx; iVar5 = curve->Midz; uVar4 = (short)uVar9 - 0x400; goto LAB_LEAD__000e82cc; @@ -1134,7 +1131,7 @@ void PosToIndex(int *normal, int *tangent, int intention, _CAR_DATA *cp) if (uVar1 < 0xf0) { - iVar6 = FIXED(*tangent * (int)rcossin_tbl[(uVar3 & 0xfff) * 2]); + iVar6 = FIXEDH(*tangent * (int)rcossin_tbl[(uVar3 & 0xfff) * 2]); if (0x7d < iVar6) { *normal = 0x17; @@ -1505,7 +1502,7 @@ void BlockToMap(MAP_DATA *data) x = data->size->vx * road_s; iVar15 = data->size->vz * road_c; - iVar9 = FIXED(y * road_s + x_00 * road_c); + iVar9 = FIXEDH(y * road_s + x_00 * road_c); if (x < 0) x = -x; @@ -1513,8 +1510,8 @@ void BlockToMap(MAP_DATA *data) if (iVar15 < 0) iVar15 = -iVar15; - someTempVar = FIXED(x + iVar15); - x = FIXED(y * road_c - x_00 * road_s); + someTempVar = FIXEDH(x + iVar15); + x = FIXEDH(y * road_c - x_00 * road_s); if ((data->intention == 0) || ((data->cp->ai.l).dstate == 3)) { @@ -1559,12 +1556,12 @@ void BlockToMap(MAP_DATA *data) y = -y; pVVar5 = data->vel; - offx = FIXED(x_00 + y) + carWidth * 2; + offx = FIXEDH(x_00 + y) + carWidth * 2; if (pVVar5 != NULL) { x_00 = pVVar5->vx * road_s + pVVar5->vz * road_c + 0x800; - y = FIXED(x_00) - (x_00 >> 0x1f) >> 1; + y = FIXEDH(x_00) - (x_00 >> 0x1f) >> 1; iVar9 = iVar9 + y; x_00 = y; @@ -1588,7 +1585,7 @@ void BlockToMap(MAP_DATA *data) right = x; if (pVVar5 != NULL) { - x_00 = FIXED(pVVar5->vx * road_c + pVVar5->vz * road_s); + x_00 = FIXEDH(pVVar5->vx * road_c + pVVar5->vz * road_s); right = x + x_00; if (x_00 < 1) @@ -1629,7 +1626,7 @@ void BlockToMap(MAP_DATA *data) if (iVar15 < 0) iVar15 = -iVar15; - someTempVar = FIXED(x + iVar15); + someTempVar = FIXEDH(x + iVar15); if (iVar14 + someTempVar < 0) return; @@ -1643,12 +1640,12 @@ void BlockToMap(MAP_DATA *data) iVar8 = -iVar8; pVVar5 = data->vel; - offx = FIXED(iVar9 + iVar8) + carWidth; + offx = FIXEDH(iVar9 + iVar8) + carWidth; if (pVVar5 != NULL) { x = pVVar5->vx * iVar12 + pVVar5->vz * iVar11 + 0x800; - iVar15 = FIXED(x) - (x >> 0x1f) >> 1; + iVar15 = FIXEDH(x) - (x >> 0x1f) >> 1; iVar14 = iVar14 + iVar15; x = iVar15; @@ -1699,7 +1696,7 @@ void BlockToMap(MAP_DATA *data) if (pVVar5 != NULL) { - x = FIXED(pVVar5->vx * iVar11 + pVVar5->vz * iVar12); + x = FIXEDH(pVVar5->vx * iVar11 + pVVar5->vz * iVar12); right = y + x; if (x < 1) { @@ -1740,7 +1737,7 @@ void BlockToMap(MAP_DATA *data) if (iVar15 < 0) iVar15 = -iVar15; - someTempVar = FIXED(x + iVar15); + someTempVar = FIXEDH(x + iVar15); x = (uVar2 - someTempVar) - carLength; if ((x < 2000) || @@ -1817,7 +1814,7 @@ void BlockToMap(MAP_DATA *data) y = (data->cp->hd).direction; - rdist = FIXED(rcossin_tbl[uVar13 * 2] * corners[left][0] + rcossin_tbl[uVar13 * 2 + 1] * corners[left][1]); + rdist = FIXEDH(rcossin_tbl[uVar13 * 2] * corners[left][0] + rcossin_tbl[uVar13 * 2 + 1] * corners[left][1]); left = corners[left][2] - y; right = corners[right][2] - y; @@ -1841,7 +1838,7 @@ void BlockToMap(MAP_DATA *data) if (x_00 < 0) x_00 = -x_00; - offx = ratan2(FIXED(iVar15 + x_00) + carWidth, x); + offx = ratan2(FIXEDH(iVar15 + x_00) + carWidth, x); left = y - offx; right = y + offx; rdist = x; @@ -2070,8 +2067,8 @@ int IsOnMap(int x, int z, VECTOR *basePos, int intention, _CAR_DATA *cp) case 0: case 2: case 3: - tangent = FIXED(dx * road_s + dz * road_c); - normal = FIXED(dx * road_c - dz * road_s); + tangent = FIXEDH(dx * road_s + dz * road_c); + normal = FIXEDH(dx * road_c - dz * road_s); PosToIndex(&normal, &tangent, intention, cp); break; case 1: @@ -2460,7 +2457,7 @@ void UpdateRoadPosition(_CAR_DATA *cp, VECTOR *basePos, int intention) if (iVar10 < 0) iVar10 = -iVar10; - size.vx = FIXED(iVar9 + iVar10); + size.vx = FIXEDH(iVar9 + iVar10); size.vy = (long)collide->ysize; if (iVar14 < 0) @@ -2469,10 +2466,10 @@ void UpdateRoadPosition(_CAR_DATA *cp, VECTOR *basePos, int intention) if (iVar8 < 0) iVar8 = -iVar8; - size.vz = FIXED(iVar14 - iVar8); + size.vz = FIXEDH(iVar14 - iVar8); } - offset.vx = FIXED(collide->xpos * matrixtable[uVar6].m[0][0] + collide->zpos * matrixtable[uVar6].m[2][0]) + (cop->pos).vx; - offset.vz = FIXED(collide->xpos * matrixtable[uVar6].m[0][2] + collide->zpos * matrixtable[uVar6].m[2][2]) + (cop->pos).vz; + offset.vx = FIXEDH(collide->xpos * matrixtable[uVar6].m[0][0] + collide->zpos * matrixtable[uVar6].m[2][0]) + (cop->pos).vx; + offset.vz = FIXEDH(collide->xpos * matrixtable[uVar6].m[0][2] + collide->zpos * matrixtable[uVar6].m[2][2]) + (cop->pos).vz; offset.vy = -(cop->pos).vy - (cop->pos).vy; vel.vx = 0; @@ -2523,7 +2520,7 @@ void UpdateRoadPosition(_CAR_DATA *cp, VECTOR *basePos, int intention) if (iVar13 < 0) iVar13 = -iVar13; - size.vx = FIXED(iVar16 + iVar13) + (int)(car_cos->colBox).vy; + size.vx = FIXEDH(iVar16 + iVar13) + (int)(car_cos->colBox).vy; size.vy = (long)(car_cos->colBox).vy; iVar16 = (uint)(ushort)(car_cos->colBox).vz << 0x10; iVar16 = (int)(lcp->hd).where.m[2][2] * ((iVar16 >> 0x10) - (iVar16 >> 0x1f) >> 1); @@ -2540,7 +2537,7 @@ void UpdateRoadPosition(_CAR_DATA *cp, VECTOR *basePos, int intention) if (iVar13 < 0) iVar13 = -iVar13; - size.vz = FIXED(iVar16 + iVar13) + (int)(car_cos->colBox).vy; + size.vz = FIXEDH(iVar16 + iVar13) + (int)(car_cos->colBox).vy; iVar16 = (cp->st).n.linearVelocity[2]; vel.vx = iVar11 >> 10; @@ -3387,7 +3384,7 @@ void CheckCurrentRoad(_CAR_DATA *cp) s = (int)rcossin_tbl[(angle & 0xfff) * 2]; c = (int)rcossin_tbl[(angle & 0xfff) * 2 + 1]; - d = FIXED(s * iVar6 + c * iVar5); + d = FIXEDH(s * iVar6 + c * iVar5); iVar2 = (cp->hd).speed; toGo = (uint)(straight->length >> 1) - d; @@ -3412,7 +3409,7 @@ void CheckCurrentRoad(_CAR_DATA *cp) if (toGo < iVar2 * 3) cp->ai.l.nextTurn = cp->ai.l.nextTurn + 0x10; - cp->ai.l.d = FIXED(-c * iVar6 + s * iVar5); + cp->ai.l.d = FIXEDH(-c * iVar6 + s * iVar5); cp->ai.l.width = ((uint)(u_char)straight->NumLanes & 0xf) << 9; } goto LAB_LEAD__000eb96c; @@ -3588,13 +3585,13 @@ LAB_LEAD__000eb96c: offx = straight->Midx - (cp->hd).where.t[0]; iVar6 = (int)rcossin_tbl[(heading & 0xfff) * 2]; offz = straight->Midz - (cp->hd).where.t[2]; - dist = -FIXED(offx * iVar6 + offz * iVar5); - cp->ai.l.d = FIXED(iVar5 * offx - iVar6 * offz); + dist = -FIXEDH(offx * iVar6 + offz * iVar5); + cp->ai.l.d = FIXEDH(iVar5 * offx - iVar6 * offz); cp->ai.l.width = ((uint)(u_char)straight->NumLanes & 0xf) << 9; - dx = FIXED(iVar6 * dist); + dx = FIXEDH(iVar6 * dist); basePosition.vx = straight->Midx + dx; basePosition.vy = (cp->hd).where.t[1]; - dz = FIXED(iVar5 * dist); + dz = FIXEDH(iVar5 * dist); basePosition.vz = straight->Midz + dz; } else if ((cr & 0xffffe000) == 0x4000) @@ -3617,8 +3614,8 @@ LAB_LEAD__000eb96c: if ((angle - heading & 0x800) == 0) { cr_00 = (uint)(ushort)curve->end & 0xfff; - basex = FIXED(rcossin_tbl[cr_00 * 2] * iVar6); - basez = FIXED(rcossin_tbl[cr_00 * 2 + 1] * iVar6); + basex = FIXEDH(rcossin_tbl[cr_00 * 2] * iVar6); + basez = FIXEDH(rcossin_tbl[cr_00 * 2 + 1] * iVar6); uVar4 = hypot(dx, dz); lVar3 = angle; cp->ai.l.d = uVar4; @@ -3630,8 +3627,8 @@ LAB_LEAD__000eb96c: else { cr_00 = (uint)(ushort)curve->start & 0xfff; - basex = FIXED(rcossin_tbl[cr_00 * 2] * iVar6); - basez = FIXED(rcossin_tbl[cr_00 * 2 + 1] * iVar6); + basex = FIXEDH(rcossin_tbl[cr_00 * 2] * iVar6); + basez = FIXEDH(rcossin_tbl[cr_00 * 2 + 1] * iVar6); uVar4 = hypot(dx, dz); lVar3 = angle; cp->ai.l.d = uVar4; @@ -3644,11 +3641,11 @@ LAB_LEAD__000eb96c: cp->ai.l.width = ((uint)(u_char)curve->NumLanes & 0xf) << 9; offx = basex - (cp->hd).where.t[0]; offz = basez - (cp->hd).where.t[2]; - dist = -FIXED(offx * rcossin_tbl[(heading & 0xfff) * 2] + offz * rcossin_tbl[(heading & 0xfff) * 2 + 1]); - dx = FIXED(rcossin_tbl[(heading & 0xfff) * 2] * dist); + dist = -FIXEDH(offx * rcossin_tbl[(heading & 0xfff) * 2] + offz * rcossin_tbl[(heading & 0xfff) * 2 + 1]); + dx = FIXEDH(rcossin_tbl[(heading & 0xfff) * 2] * dist); basePosition.vx = basex + dx; basePosition.vy = (cp->hd).where.t[1]; - dz = FIXED(rcossin_tbl[(heading & 0xfff) * 2 + 1] * dist); + dz = FIXEDH(rcossin_tbl[(heading & 0xfff) * 2 + 1] * dist); basePosition.vz = basez + dz; } else @@ -3821,8 +3818,8 @@ void SetTarget(_CAR_DATA *cp, int cr, int heading, int *nextJunction) cp->ai.l.targetDir = uVar3; uVar4 = (uint)uVar3 & 0xfff; - dx = FIXED(rcossin_tbl[uVar4 * 2 + 1] * iVar8); - dz = FIXED(rcossin_tbl[uVar4 * 2] * iVar8); + dx = FIXEDH(rcossin_tbl[uVar4 * 2 + 1] * iVar8); + dz = FIXEDH(rcossin_tbl[uVar4 * 2] * iVar8); cp->ai.l.targetX = (cp->hd).where.t[0] + dx; cp->ai.l.targetZ = (cp->hd).where.t[2] + dz; @@ -3862,11 +3859,11 @@ void SetTarget(_CAR_DATA *cp, int cr, int heading, int *nextJunction) iVar7 = cp->ai.l.roadForward; uVar5 = (uint)(ushort)cp->ai.l.targetDir & 0xfff; sVar2 = rcossin_tbl[uVar5 * 2 + 1]; - iVar8 = FIXED(rcossin_tbl[uVar4 * 2] * (straight->Midx - iVar10) + sVar1 * (straight->Midz - iVar9)) + + iVar8 = FIXEDH(rcossin_tbl[uVar4 * 2] * (straight->Midx - iVar10) + sVar1 * (straight->Midz - iVar9)) + ((uint)(u_char)straight->NumLanes & 0xf) * -0x200 + cp->ai.l.roadPosition; - cp->ai.l.targetX = iVar10 + FIXED(rcossin_tbl[uVar5 * 2] * iVar7) + FIXED(iVar8 * rcossin_tbl[uVar4 * 2]); - cp->ai.l.targetZ = iVar9 + FIXED(sVar2 * iVar7) + FIXED(iVar8 * sVar1); + cp->ai.l.targetX = iVar10 + FIXEDH(rcossin_tbl[uVar5 * 2] * iVar7) + FIXEDH(iVar8 * rcossin_tbl[uVar4 * 2]); + cp->ai.l.targetZ = iVar9 + FIXEDH(sVar2 * iVar7) + FIXEDH(iVar8 * sVar1); return; } @@ -3910,8 +3907,8 @@ void SetTarget(_CAR_DATA *cp, int cr, int heading, int *nextJunction) *nextJunction = iVar7; } - cp->ai.l.targetX = curve->Midx + FIXED(iVar8 * rcossin_tbl[(uVar4 & 0xfff) * 2]); - cp->ai.l.targetZ = curve->Midz + FIXED(iVar8 * rcossin_tbl[(uVar4 & 0xfff) * 2 + 1]); + cp->ai.l.targetX = curve->Midx + FIXEDH(iVar8 * rcossin_tbl[(uVar4 & 0xfff) * 2]); + cp->ai.l.targetZ = curve->Midz + FIXEDH(iVar8 * rcossin_tbl[(uVar4 & 0xfff) * 2 + 1]); } diff --git a/src_rebuild/GAME/C/MOTION_C.C b/src_rebuild/GAME/C/MOTION_C.C index fced9f58..84cfb78a 100644 --- a/src_rebuild/GAME/C/MOTION_C.C +++ b/src_rebuild/GAME/C/MOTION_C.C @@ -578,8 +578,8 @@ void DrawBodySprite(PEDESTRIAN *pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP width = MainPed[bone].cWidth; } - iVar5 = FIXED(iVar13 * rcossin_tbl[(-lVar2 & 0xfffU) * 2] * 2 * (width & 0x3f)); - iVar7 = FIXED(iVar13 * rcossin_tbl[(-lVar2 & 0xfffU) * 2 + 1] * 2 * (width & 0x3f)); + iVar5 = FIXEDH(iVar13 * rcossin_tbl[(-lVar2 & 0xfffU) * 2] * 2 * (width & 0x3f)); + iVar7 = FIXEDH(iVar13 * rcossin_tbl[(-lVar2 & 0xfffU) * 2 + 1] * 2 * (width & 0x3f)); bVar3 = MainPed[bone].cAdj & 0xf; iVar9 = y >> bVar3; @@ -600,17 +600,17 @@ void DrawBodySprite(PEDESTRIAN *pDrawingPed, int boneId, VERTTYPE v1[2], VERTTYP prims = (POLY_FT4 *)current->primptr; setPolyFT4(prims); - prims->x0 = v1[0] + FIXED(iVar5) + iVar8; - prims->y0 = v1[1] + FIXED(iVar7) + iVar9; + prims->x0 = v1[0] + FIXEDH(iVar5) + iVar8; + prims->y0 = v1[1] + FIXEDH(iVar7) + iVar9; - prims->x1 = (v1[0] - FIXED(iVar5)) + iVar8; - prims->y1 = (v1[1] - FIXED(iVar7)) + iVar9; + prims->x1 = (v1[0] - FIXEDH(iVar5)) + iVar8; + prims->y1 = (v1[1] - FIXEDH(iVar7)) + iVar9; - prims->x2 = (v2[0] + FIXED(iVar5)) - x; - prims->y2 = (v2[1] + FIXED(iVar7)) - y; + prims->x2 = (v2[0] + FIXEDH(iVar5)) - x; + prims->y2 = (v2[1] + FIXEDH(iVar7)) - y; - prims->x3 = (v2[0] - FIXED(iVar5)) - x; - prims->y3 = (v2[1] - FIXED(iVar7)) - y; + prims->x3 = (v2[0] - FIXEDH(iVar5)) - x; + prims->y3 = (v2[1] - FIXEDH(iVar7)) - y; if (bDoingShadow == 0) { @@ -1639,12 +1639,12 @@ void newRotateBones(PEDESTRIAN *pDrawingPed, BONE *poBone) iVar12 = (int)rcossin_tbl[uVar11 * 2]; iVar13 = (int)rcossin_tbl[uVar10 * 2]; - uVar10 = FIXED(iVar14 * iVar13) + FIXED(FIXED(iVar6 * iVar12) * iVar17); - uVar16 = FIXED(iVar6 * iVar15); + uVar10 = FIXEDH(iVar14 * iVar13) + FIXEDH(FIXEDH(iVar6 * iVar12) * iVar17); + uVar16 = FIXEDH(iVar6 * iVar15); iVar7 = uVar16; - uVar9 = -FIXED(iVar15 * iVar12); - uVar11 = FIXED(iVar14 * iVar15); - iVar6 = FIXED(-iVar14 * FIXED(iVar6 * iVar17)) + FIXED(iVar12 * iVar13); + uVar9 = -FIXEDH(iVar15 * iVar12); + uVar11 = FIXEDH(iVar14 * iVar15); + iVar6 = FIXEDH(-iVar14 * FIXEDH(iVar6 * iVar17)) + FIXEDH(iVar12 * iVar13); MATRIX_1f800020.m[0][0] = uVar16; MATRIX_1f800020.m[0][1] = iVar6; @@ -1654,9 +1654,9 @@ void newRotateBones(PEDESTRIAN *pDrawingPed, BONE *poBone) MATRIX_1f800020.m[1][1] = uVar11; MATRIX_1f800020.m[1][2] = uVar9; - MATRIX_1f800020.m[2][0] = -FIXED(iVar13 * iVar15); - MATRIX_1f800020.m[2][1] = FIXED(uVar10 * iVar17) - FIXED(iVar7 * uVar9); - MATRIX_1f800020.m[2][2] = FIXED(iVar7 * uVar11) - FIXED(iVar6 * iVar17); + MATRIX_1f800020.m[2][0] = -FIXEDH(iVar13 * iVar15); + MATRIX_1f800020.m[2][1] = FIXEDH(uVar10 * iVar17) - FIXEDH(iVar7 * uVar9); + MATRIX_1f800020.m[2][2] = FIXEDH(iVar7 * uVar11) - FIXEDH(iVar6 * iVar17); } SVECTOR_ARRAY_1f800060[0].vx = Skel[0].vOffset.vx; @@ -1998,12 +1998,12 @@ void DrawCiv(PEDESTRIAN *pPed) iVar12 = (int)rcossin_tbl[uVar11 * 2]; iVar13 = (int)rcossin_tbl[uVar10 * 2]; - uVar10 = FIXED(iVar14 * iVar13) + FIXED(FIXED(iVar6 * iVar12) * iVar17); - uVar16 = FIXED(iVar6 * iVar15); + uVar10 = FIXEDH(iVar14 * iVar13) + FIXEDH(FIXEDH(iVar6 * iVar12) * iVar17); + uVar16 = FIXEDH(iVar6 * iVar15); iVar7 = uVar16; - uVar9 = -FIXED(iVar15 * iVar12); - uVar11 = FIXED(iVar14 * iVar15); - iVar6 = FIXED(-iVar14 * FIXED(iVar6 * iVar17)) + FIXED(iVar12 * iVar13); + uVar9 = -FIXEDH(iVar15 * iVar12); + uVar11 = FIXEDH(iVar14 * iVar15); + iVar6 = FIXEDH(-iVar14 * FIXEDH(iVar6 * iVar17)) + FIXEDH(iVar12 * iVar13); workmatrix.m[0][0] = uVar16; workmatrix.m[0][1] = iVar6; @@ -2013,9 +2013,9 @@ void DrawCiv(PEDESTRIAN *pPed) workmatrix.m[1][1] = uVar11; workmatrix.m[1][2] = uVar9; - workmatrix.m[2][0] = -FIXED(iVar13 * iVar15); - workmatrix.m[2][1] = FIXED(uVar10 * iVar17) - FIXED(iVar7 * uVar9); - workmatrix.m[2][2] = FIXED(iVar7 * uVar11) - FIXED(iVar6 * iVar17); + workmatrix.m[2][0] = -FIXEDH(iVar13 * iVar15); + workmatrix.m[2][1] = FIXEDH(uVar10 * iVar17) - FIXEDH(iVar7 * uVar9); + workmatrix.m[2][2] = FIXEDH(iVar7 * uVar11) - FIXEDH(iVar6 * iVar17); } gte_MulMatrix0(&inv_camera_matrix, &workmatrix, &workmatrix); diff --git a/src_rebuild/GAME/C/OBJCOLL.C b/src_rebuild/GAME/C/OBJCOLL.C index efa3daf9..fee88236 100644 --- a/src_rebuild/GAME/C/OBJCOLL.C +++ b/src_rebuild/GAME/C/OBJCOLL.C @@ -570,8 +570,8 @@ char lineClear(VECTOR *v1, VECTOR *v2) cs = rcossin_tbl[local_a3_704 * 2 + 1]; sn = rcossin_tbl[local_a3_704 * 2]; - iVar4 = va.vx - (pCellObject->pos.vx + FIXED(collide->xpos * mat->m[0][0] + collide->zpos * mat->m[2][0])); - iVar3 = va.vz - (pCellObject->pos.vz + FIXED(collide->xpos * mat->m[0][2] + collide->zpos * mat->m[2][2])); + iVar4 = va.vx - (pCellObject->pos.vx + FIXEDH(collide->xpos * mat->m[0][0] + collide->zpos * mat->m[2][0])); + iVar3 = va.vz - (pCellObject->pos.vz + FIXEDH(collide->xpos * mat->m[0][2] + collide->zpos * mat->m[2][2])); box.slab[0].upper = collide->xsize / 2 +testRadius; box.slab[0].lower = -box.slab[0].upper; @@ -582,12 +582,12 @@ char lineClear(VECTOR *v1, VECTOR *v2) box.slab[2].upper = collide->zsize / 2 +testRadius; box.slab[2].lower = -box.slab[2].upper; - ray.org[0] = FIXED(cs * iVar4 - sn * iVar3); - ray.org[2] = FIXED(cs * iVar3 + sn * iVar4); + ray.org[0] = FIXEDH(cs * iVar4 - sn * iVar3); + ray.org[2] = FIXEDH(cs * iVar3 + sn * iVar4); ray.org[1] = (va.vy - (((-collide->ypos - pCellObject->pos.vy) * 0x10000) >> 0x10)) + 80; - ray.dir[0] = FIXED(cs * pos.vx - sn * pos.vz); - ray.dir[2] = FIXED(cs * pos.vz + sn * pos.vx); + ray.dir[0] = FIXEDH(cs * pos.vx - sn * pos.vz); + ray.dir[2] = FIXEDH(cs * pos.vz + sn * pos.vx); ray.dir[1] = vb.vy - va.vy; #if defined(COLLISION_DEBUG) @@ -598,8 +598,8 @@ char lineClear(VECTOR *v1, VECTOR *v2) { CDATA2D cd[1]; - cd[0].x.vx = (pCellObject->pos.vx + FIXED(collide->xpos * mat->m[0][0] + collide->zpos * mat->m[2][0])); - cd[0].x.vz = (pCellObject->pos.vz + FIXED(collide->xpos * mat->m[0][2] + collide->zpos * mat->m[2][2])); + cd[0].x.vx = (pCellObject->pos.vx + FIXEDH(collide->xpos * mat->m[0][0] + collide->zpos * mat->m[2][0])); + cd[0].x.vz = (pCellObject->pos.vz + FIXEDH(collide->xpos * mat->m[0][2] + collide->zpos * mat->m[2][2])); cd[0].x.vy = va.vy; cd[0].theta = (pCellObject->yang + collide->yang) * 64 & 0xfff; @@ -631,10 +631,10 @@ char lineClear(VECTOR *v1, VECTOR *v2) //Debug_AddLine(b1p1, b2p1, yycv); VECTOR b1ax[2] = { {0} , {0} }; - b1ax[0].vx = FIXED(cd[0].axis[0].vx * cd[0].length[0]); - b1ax[0].vz = FIXED(cd[0].axis[0].vz * cd[0].length[0]); - b1ax[1].vx = FIXED(cd[0].axis[1].vx * cd[0].length[1]); - b1ax[1].vz = FIXED(cd[0].axis[1].vz * cd[0].length[1]); + b1ax[0].vx = FIXEDH(cd[0].axis[0].vx * cd[0].length[0]); + b1ax[0].vz = FIXEDH(cd[0].axis[0].vz * cd[0].length[0]); + b1ax[1].vx = FIXEDH(cd[0].axis[1].vx * cd[0].length[1]); + b1ax[1].vz = FIXEDH(cd[0].axis[1].vz * cd[0].length[1]); // show axis of body 1 Debug_AddLineOfs(_zero, b1ax[0], b1p, rrcv); @@ -1019,9 +1019,9 @@ void CheckScenaryCollisions(_CAR_DATA *cp) // box 'rotated' by matrix // [A] FIXME: replace add+shift by division - bbox.pos.vx = cop->pos.vx + FIXED(collide->xpos * matrixtable[uVar9].m[0][0] + collide->zpos * matrixtable[uVar9].m[2][0]); + bbox.pos.vx = cop->pos.vx + FIXEDH(collide->xpos * matrixtable[uVar9].m[0][0] + collide->zpos * matrixtable[uVar9].m[2][0]); bbox.pos.vy = cop->pos.vy + collide->ypos; - bbox.pos.vz = cop->pos.vz + FIXED(collide->xpos * matrixtable[uVar9].m[0][2] + collide->zpos * matrixtable[uVar9].m[2][2]); + bbox.pos.vz = cop->pos.vz + FIXEDH(collide->xpos * matrixtable[uVar9].m[0][2] + collide->zpos * matrixtable[uVar9].m[2][2]); bbox.pos.pad = (model->flags2 >> 10) & 1; @@ -1073,8 +1073,8 @@ void CheckScenaryCollisions(_CAR_DATA *cp) iVar13 = gCameraDistance; uVar9 = cp->hd.direction & 0xfff; - cp->hd.where.t[0] = lVar1 + FIXED((gCameraDistance * rcossin_tbl[uVar9 * 2]) / 2); - cp->hd.where.t[2] = lVar2 + FIXED((iVar13 * rcossin_tbl[uVar9 * 2 + 1]) / 2); + cp->hd.where.t[0] = lVar1 + FIXEDH((gCameraDistance * rcossin_tbl[uVar9 * 2]) / 2); + cp->hd.where.t[2] = lVar2 + FIXEDH((iVar13 * rcossin_tbl[uVar9 * 2 + 1]) / 2); iVar7--; } } @@ -1253,8 +1253,8 @@ int QuickBuildingCollisionCheck(VECTOR *pPos, int dir, int l, int w, int extra) cd[0].vel.vx = 0; cd[0].vel.vz = 0; - offset.vx = cop->pos.vx + FIXED(collide->xpos * matrixtable[uVar9].m[0][0] + collide->zpos * matrixtable[uVar9].m[2][0]); - offset.vz = cop->pos.vz + FIXED(collide->xpos * matrixtable[uVar9].m[0][2] + collide->zpos * matrixtable[uVar9].m[2][2]); + offset.vx = cop->pos.vx + FIXEDH(collide->xpos * matrixtable[uVar9].m[0][0] + collide->zpos * matrixtable[uVar9].m[2][0]); + offset.vz = cop->pos.vz + FIXEDH(collide->xpos * matrixtable[uVar9].m[0][2] + collide->zpos * matrixtable[uVar9].m[2][2]); cd[1].theta = (cop->yang + collide->yang) * 64 & 0xfff; @@ -1292,10 +1292,10 @@ int QuickBuildingCollisionCheck(VECTOR *pPos, int dir, int l, int w, int extra) //Debug_AddLine(b1p1, b2p1, yycv); VECTOR b1ax[2] = { {0} , {0} }; - b1ax[0].vx = FIXED(cd[0].axis[0].vx * cd[0].length[0]); - b1ax[0].vz = FIXED(cd[0].axis[0].vz * cd[0].length[0]); - b1ax[1].vx = FIXED(cd[0].axis[1].vx * cd[0].length[1]); - b1ax[1].vz = FIXED(cd[0].axis[1].vz * cd[0].length[1]); + b1ax[0].vx = FIXEDH(cd[0].axis[0].vx * cd[0].length[0]); + b1ax[0].vz = FIXEDH(cd[0].axis[0].vz * cd[0].length[0]); + b1ax[1].vx = FIXEDH(cd[0].axis[1].vx * cd[0].length[1]); + b1ax[1].vz = FIXEDH(cd[0].axis[1].vz * cd[0].length[1]); // show axis of body 1 Debug_AddLineOfs(_zero, b1ax[0], b1p, rrcv); @@ -1319,10 +1319,10 @@ int QuickBuildingCollisionCheck(VECTOR *pPos, int dir, int l, int w, int extra) } VECTOR b2ax[2] = { {0} , {0} }; - b2ax[0].vx += FIXED(cd[1].axis[0].vx * cd[1].length[0]); - b2ax[0].vz += FIXED(cd[1].axis[0].vz * cd[1].length[0]); - b2ax[1].vx += FIXED(cd[1].axis[1].vx * cd[1].length[1]); - b2ax[1].vz += FIXED(cd[1].axis[1].vz * cd[1].length[1]); + b2ax[0].vx += FIXEDH(cd[1].axis[0].vx * cd[1].length[0]); + b2ax[0].vz += FIXEDH(cd[1].axis[0].vz * cd[1].length[0]); + b2ax[1].vx += FIXEDH(cd[1].axis[1].vx * cd[1].length[1]); + b2ax[1].vz += FIXEDH(cd[1].axis[1].vz * cd[1].length[1]); // show axis of body 2 Debug_AddLineOfs(_zero, b2ax[0], b2p, rrcv); diff --git a/src_rebuild/GAME/C/OVERMAP.C b/src_rebuild/GAME/C/OVERMAP.C index 2c6666c4..f4334f9c 100644 --- a/src_rebuild/GAME/C/OVERMAP.C +++ b/src_rebuild/GAME/C/OVERMAP.C @@ -456,13 +456,13 @@ void DrawPlayerDot(VECTOR *pos, short rot, unsigned char r, unsigned char g, int opos[2].vz = vec.vz; opos[0].vx = opos[2].vx + (iVar2 * -3 + 0x800 >> 0xc); - opos[0].vz = opos[2].vz + FIXED(iVar3 * -3); + opos[0].vz = opos[2].vz + FIXEDH(iVar3 * -3); - opos[1].vx = opos[2].vx + FIXED(iVar2 * 3 + iVar3 * -2); - opos[1].vz = opos[2].vz + FIXED(iVar3 * 3 + iVar2 * 2); + opos[1].vx = opos[2].vx + FIXEDH(iVar2 * 3 + iVar3 * -2); + opos[1].vz = opos[2].vz + FIXEDH(iVar3 * 3 + iVar2 * 2); - opos[2].vx = opos[2].vx + FIXED(iVar3 * 2 + iVar2 * 3); - opos[2].vz = opos[2].vz + FIXED(iVar2 * -2 + iVar3 * 3); + opos[2].vx = opos[2].vx + FIXEDH(iVar3 * 2 + iVar2 * 3); + opos[2].vz = opos[2].vz + FIXEDH(iVar2 * -2 + iVar3 * 3); poly = (POLY_F3 *)current->primptr; setPolyF3(poly); @@ -1779,10 +1779,10 @@ void DrawCopIndicators(void) iVar6 = cp->hd.where.t[0] - player[0].pos[0]; iVar4 = cp->hd.where.t[2] - player[0].pos[2]; - iVar5 = FIXED(iVar6 * sVar1 - iVar4 * sVar2) * 3; + iVar5 = FIXEDH(iVar6 * sVar1 - iVar4 * sVar2) * 3; iVar5 = iVar5 >> 2; - iVar3 = FIXED(iVar6 * sVar2 + iVar4 * sVar1); + iVar3 = FIXEDH(iVar6 * sVar2 + iVar4 * sVar1); iVar4 = -iVar3; iVar6 = iVar5; @@ -3002,8 +3002,8 @@ void DrawSightCone(COP_SIGHT_DATA *pCopSightData, VECTOR *pPosition, int directi uVar7 = iVar9 + direction & 0xfff; iVar9 = iVar9 + 0x200; - pVertex->vx = vertex[0].vx + FIXED(rcossin_tbl[uVar7 * 2] * sVar4); - pVertex->vz = vertex[0].vz + FIXED(rcossin_tbl[uVar7 * 2 + 1] * sVar4); + pVertex->vx = vertex[0].vx + FIXEDH(rcossin_tbl[uVar7 * 2] * sVar4); + pVertex->vz = vertex[0].vz + FIXEDH(rcossin_tbl[uVar7 * 2 + 1] * sVar4); pVertex = pVertex + 1; } while (iVar9 < 0x1000); diff --git a/src_rebuild/GAME/C/PATHFIND.C b/src_rebuild/GAME/C/PATHFIND.C index b3911d14..934b9387 100644 --- a/src_rebuild/GAME/C/PATHFIND.C +++ b/src_rebuild/GAME/C/PATHFIND.C @@ -2092,9 +2092,9 @@ void UpdateCopMap(void) { iVar1 = (int)player[0].playerCarId; - searchTarget.vx = car_data[iVar1].hd.where.t[0] + FIXED(car_data[iVar1].st.n.linearVelocity[0]) * 8; - searchTarget.vy = car_data[iVar1].hd.where.t[1] + FIXED(car_data[iVar1].st.n.linearVelocity[1]) * 4; - searchTarget.vz = car_data[iVar1].hd.where.t[2] + FIXED(car_data[iVar1].st.n.linearVelocity[2]) * 8; + searchTarget.vx = car_data[iVar1].hd.where.t[0] + FIXEDH(car_data[iVar1].st.n.linearVelocity[0]) * 8; + searchTarget.vy = car_data[iVar1].hd.where.t[1] + FIXEDH(car_data[iVar1].st.n.linearVelocity[1]) * 4; + searchTarget.vz = car_data[iVar1].hd.where.t[2] + FIXEDH(car_data[iVar1].st.n.linearVelocity[2]) * 8; } else if (searchTarget.vy == -0x304f) { diff --git a/src_rebuild/GAME/C/PEDEST.C b/src_rebuild/GAME/C/PEDEST.C index 2cf8f512..6a8b2415 100644 --- a/src_rebuild/GAME/C/PEDEST.C +++ b/src_rebuild/GAME/C/PEDEST.C @@ -186,9 +186,9 @@ void IHaveThePower(void) cp->hd.acc[1] += force[1]; cp->hd.acc[2] += force[2]; - cp->hd.aacc[0] += FIXED(point[1] * force[2] - point[2] * force[1]); - cp->hd.aacc[1] += FIXED(point[2] * force[0] - point[0] * force[2]); - cp->hd.aacc[2] += FIXED(point[0] * force[1] - point[1] * force[0]); + cp->hd.aacc[0] += FIXEDH(point[1] * force[2] - point[2] * force[1]); + cp->hd.aacc[1] += FIXEDH(point[2] * force[0] - point[0] * force[2]); + cp->hd.aacc[2] += FIXEDH(point[0] * force[1] - point[1] * force[0]); } cp++; @@ -3281,8 +3281,8 @@ void PingInPedestrians(void) pinginPedAngle = pinginPedAngle + 0x51; iVar8 = lVar5 - FixFloorSigned(lVar7, 7) * 128 + 0x600; randomLoc.vy = baseLoc.vy; - randomLoc.vx = baseLoc.vx + iVar8 * FIXED((int)rcossin_tbl[(pinginPedAngle & 0xfffU) * 2] * 8); - randomLoc.vz = baseLoc.vz + iVar8 * FIXED((int)rcossin_tbl[(pinginPedAngle & 0xfffU) * 2 + 1] * 8); + randomLoc.vx = baseLoc.vx + iVar8 * FIXEDH((int)rcossin_tbl[(pinginPedAngle & 0xfffU) * 2] * 8); + randomLoc.vz = baseLoc.vz + iVar8 * FIXEDH((int)rcossin_tbl[(pinginPedAngle & 0xfffU) * 2 + 1] * 8); iVar8 = MapHeight(&randomLoc); randomLoc.vy = -iVar8; @@ -3703,22 +3703,22 @@ int TannerCarCollisionCheck(VECTOR *pPos, int dir, int bQuick) if (bQuick != 0) return 1; - if (50 < FIXED(cp1->hd.wheel_speed)) + if (50 < FIXEDH(cp1->hd.wheel_speed)) return 1; bFindCollisionPoint(cd, &collisionResult); iVar3 = -collisionResult.surfNormal.vz; iVar1 = -collisionResult.surfNormal.vx; - iVar10 = pcdTanner->hd.where.t[2] + FIXED(collisionResult.penetration * iVar3); + iVar10 = pcdTanner->hd.where.t[2] + FIXEDH(collisionResult.penetration * iVar3); iVar12 = collisionResult.hit.vz - iVar10; collisionResult.hit.vy = pcdTanner->hd.where.t[1] + 0x3c; iVar9 = collisionResult.hit.vy - pcdTanner->hd.where.t[1]; - iVar8 = pcdTanner->hd.where.t[0] + FIXED(collisionResult.penetration * iVar1); + iVar8 = pcdTanner->hd.where.t[0] + FIXEDH(collisionResult.penetration * iVar1); iVar11 = collisionResult.hit.vx - iVar8; collisionResult.surfNormal.vy = 0; - iVar7 = FIXED(pcdTanner->st.n.angularVelocity[1] * iVar12 - pcdTanner->st.n.angularVelocity[2] * iVar9) + pcdTanner->st.n.linearVelocity[0]; - iVar5 = FIXED(pcdTanner->st.n.angularVelocity[0] * iVar9 - pcdTanner->st.n.angularVelocity[1] * iVar11) + pcdTanner->st.n.linearVelocity[2]; + iVar7 = FIXEDH(pcdTanner->st.n.angularVelocity[1] * iVar12 - pcdTanner->st.n.angularVelocity[2] * iVar9) + pcdTanner->st.n.linearVelocity[0]; + iVar5 = FIXEDH(pcdTanner->st.n.angularVelocity[0] * iVar9 - pcdTanner->st.n.angularVelocity[1] * iVar11) + pcdTanner->st.n.linearVelocity[2]; iVar4 = iVar1; iVar6 = iVar3; @@ -3727,8 +3727,8 @@ int TannerCarCollisionCheck(VECTOR *pPos, int dir, int bQuick) if (iVar5 < 0) { - iVar7 = FIXED(iVar11 * iVar1 + iVar12 * iVar3); - iVar7 = FIXED(((iVar11 * iVar11 + iVar12 * iVar12) - iVar7 * iVar7) * car_cosmetics[pcdTanner->ap.model].twistRateY) + 0x1000; + iVar7 = FIXEDH(iVar11 * iVar1 + iVar12 * iVar3); + iVar7 = FIXEDH(((iVar11 * iVar11 + iVar12 * iVar12) - iVar7 * iVar7) * car_cosmetics[pcdTanner->ap.model].twistRateY) + 0x1000; if (-iVar5 < 0x7f001) iVar5 = (iVar5 * -0x1000) / iVar7; @@ -3744,16 +3744,16 @@ int TannerCarCollisionCheck(VECTOR *pPos, int dir, int bQuick) pcdTanner->st.n.linearVelocity[0] = pcdTanner->st.n.linearVelocity[0] + iVar4; pcdTanner->st.n.linearVelocity[2] = pcdTanner->st.n.linearVelocity[2] + iVar5; - pcdTanner->hd.aacc[2] = pcdTanner->hd.aacc[2] - FIXED(iVar9 * iVar4); - pcdTanner->hd.aacc[0] = pcdTanner->hd.aacc[0] + FIXED(iVar9 * iVar5); + pcdTanner->hd.aacc[2] = pcdTanner->hd.aacc[2] - FIXEDH(iVar9 * iVar4); + pcdTanner->hd.aacc[0] = pcdTanner->hd.aacc[0] + FIXEDH(iVar9 * iVar5); - pcdTanner->hd.aacc[1] = (pcdTanner->hd.aacc[1] + FIXED(iVar12 * iVar4)) - FIXED(iVar11 * iVar5); + pcdTanner->hd.aacc[1] = (pcdTanner->hd.aacc[1] + FIXEDH(iVar12 * iVar4)) - FIXEDH(iVar11 * iVar5); collisionResult.hit.vy = -collisionResult.hit.vy; } - pcdTanner->hd.where.t[0] = iVar8 - FIXED(pcdTanner->st.n.linearVelocity[0]); - pcdTanner->hd.where.t[2] = iVar10 - FIXED(pcdTanner->st.n.linearVelocity[2]); + pcdTanner->hd.where.t[0] = iVar8 - FIXEDH(pcdTanner->st.n.linearVelocity[0]); + pcdTanner->hd.where.t[2] = iVar10 - FIXEDH(pcdTanner->st.n.linearVelocity[2]); collisionResult.surfNormal.vx = iVar1; collisionResult.surfNormal.vz = iVar3; @@ -4504,29 +4504,17 @@ int IsPavement(int x, int y, int z, PEDESTRIAN *pPed) // [D] void SetPedestrianTurn(PEDESTRIAN *pedestrian, int turn) { - char cVar1; - short sVar2; - short sVar3; - int iVar4; - int iVar5; - uint uVar6; + int uVar6; - iVar4 = (pedestrian->position).vx; - sVar2 = (pedestrian->velocity).vz; - iVar5 = (pedestrian->position).vz; - - uVar6 = (pedestrian->dir).vy + turn & 0xfff; - (pedestrian->dir).vy = (short)uVar6; + pedestrian->dir.vy = pedestrian->dir.vy + turn & 0xfff; uVar6 = uVar6 + 0x800 & 0xfff; - sVar3 = (pedestrian->velocity).vx; - (pedestrian->position).vz = iVar5 - sVar2; + pedestrian->position.vz = pedestrian->position.vz - pedestrian->velocity.vz; + pedestrian->position.vx = pedestrian->position.vx - pedestrian->velocity.vx; - cVar1 = pedestrian->speed; - (pedestrian->position).vx = iVar4 - sVar3; - (pedestrian->velocity).vx = FIXED(cVar1 * rcossin_tbl[uVar6 * 2]); - (pedestrian->velocity).vz = FIXED(cVar1 * rcossin_tbl[uVar6 * 2 + 1]); + pedestrian->velocity.vx = FIXED(pedestrian->speed * rcossin_tbl[uVar6 * 2]); + pedestrian->velocity.vz = FIXED(pedestrian->speed * rcossin_tbl[uVar6 * 2 + 1]); } diff --git a/src_rebuild/GAME/C/SKY.C b/src_rebuild/GAME/C/SKY.C index e583682c..10b7ad8d 100644 --- a/src_rebuild/GAME/C/SKY.C +++ b/src_rebuild/GAME/C/SKY.C @@ -1033,11 +1033,11 @@ void TunnelSkyFade(void) { if (pVVar5 != NULL) { - iVar1 = FIXED(pVVar6->vx - player[0].pos[0]); - iVar3 = FIXED(pVVar6->vz - player[0].pos[2]); + iVar1 = FIXEDH(pVVar6->vx - player[0].pos[0]); + iVar3 = FIXEDH(pVVar6->vz - player[0].pos[2]); - iVar2 = FIXED(pVVar5->vx - player[0].pos[0]); - iVar4 = FIXED(pVVar5->vz - player[0].pos[2]); + iVar2 = FIXEDH(pVVar5->vx - player[0].pos[0]); + iVar4 = FIXEDH(pVVar5->vz - player[0].pos[2]); iVar3 = iVar1 * iVar1 + iVar3 * iVar3; iVar4 = iVar2 * iVar2 + iVar4 * iVar4; @@ -1052,8 +1052,8 @@ void TunnelSkyFade(void) iVar3 = pVVar6->vz; } - iVar4 = FIXED(iVar4 - player[0].pos[0]); - iVar3 = FIXED(iVar3 - player[0].pos[2]); + iVar4 = FIXEDH(iVar4 - player[0].pos[0]); + iVar3 = FIXEDH(iVar3 - player[0].pos[2]); iVar3 = iVar4 * iVar4 + iVar3 * iVar3; diff --git a/src_rebuild/GAME/C/SOUND.C b/src_rebuild/GAME/C/SOUND.C index fbd4e172..b2b17e97 100644 --- a/src_rebuild/GAME/C/SOUND.C +++ b/src_rebuild/GAME/C/SOUND.C @@ -758,9 +758,9 @@ void ComputeDoppler(CHANNEL_DATA *ch) srcPos = ch->srcposition; srcVel = ch->srcvelocity; - iVar6 = (srcPos->vx - pl->cameraPos.vx) + FIXED(srcVel[0] - pl->camera_vel[0]); - iVar4 = (srcPos->vy + pl->cameraPos.vy) + FIXED(srcVel[1] - pl->camera_vel[1]); - iVar1 = (srcPos->vz - pl->cameraPos.vz) + FIXED(srcVel[2] - pl->camera_vel[2]); + iVar6 = (srcPos->vx - pl->cameraPos.vx) + FIXEDH(srcVel[0] - pl->camera_vel[0]); + iVar4 = (srcPos->vy + pl->cameraPos.vy) + FIXEDH(srcVel[1] - pl->camera_vel[1]); + iVar1 = (srcPos->vz - pl->cameraPos.vz) + FIXEDH(srcVel[2] - pl->camera_vel[2]); lVar3 = jsqrt(iVar6 * iVar6 + iVar4 * iVar4 + iVar1 * iVar1); diff --git a/src_rebuild/GAME/C/WHEELFORCES.C b/src_rebuild/GAME/C/WHEELFORCES.C index 0d9532f5..ff2afc63 100644 --- a/src_rebuild/GAME/C/WHEELFORCES.C +++ b/src_rebuild/GAME/C/WHEELFORCES.C @@ -292,8 +292,8 @@ void StepOneCar(_CAR_DATA *cp) cp->hd.acc[1] = -7456; // apply gravity cp->hd.acc[2] = 0; - iVar12 = FIXED(_cl.vel[0]); - iVar4 = FIXED(_cl.vel[2]); + iVar12 = FIXEDH(_cl.vel[0]); + iVar4 = FIXEDH(_cl.vel[2]); if (iVar12 < 0) iVar12 = -iVar12; @@ -339,7 +339,7 @@ void StepOneCar(_CAR_DATA *cp) if((surfacePoint[1] - pointPos[1]) - 1 < 799) { - iVar4 = FIXED((surfacePoint[1] - pointPos[1]) * surfaceNormal[1]); + iVar4 = FIXEDH((surfacePoint[1] - pointPos[1]) * surfaceNormal[1]); if (iVar12 < iVar4) { @@ -370,12 +370,12 @@ void StepOneCar(_CAR_DATA *cp) if (iVar12 != 0) { - reaction[0] = FIXED(_cl.avel[1] * deepestLever[2] - _cl.avel[2] * deepestLever[1]) + _cl.vel[0]; - reaction[1] = FIXED(_cl.avel[2] * deepestLever[0] - _cl.avel[0] * deepestLever[2]) + _cl.vel[1]; - reaction[2] = FIXED(_cl.avel[0] * deepestLever[1] - _cl.avel[1] * deepestLever[0]) + _cl.vel[2]; + reaction[0] = FIXEDH(_cl.avel[1] * deepestLever[2] - _cl.avel[2] * deepestLever[1]) + _cl.vel[0]; + reaction[1] = FIXEDH(_cl.avel[2] * deepestLever[0] - _cl.avel[0] * deepestLever[2]) + _cl.vel[1]; + reaction[2] = FIXEDH(_cl.avel[0] * deepestLever[1] - _cl.avel[1] * deepestLever[0]) + _cl.vel[2]; - iVar4 = FIXED(deepestLever[0] * deepestNormal[0] + deepestLever[1] * deepestNormal[1] + deepestLever[2] * deepestNormal[2]); - iVar4 = FIXED(((deepestLever[0] * deepestLever[0] + deepestLever[1] * deepestLever[1] + deepestLever[2] * deepestLever[2]) - iVar4 * iVar4) * car_cosmetics[cp->ap.model].twistRateY) + 4096; + iVar4 = FIXEDH(deepestLever[0] * deepestNormal[0] + deepestLever[1] * deepestNormal[1] + deepestLever[2] * deepestNormal[2]); + iVar4 = FIXEDH(((deepestLever[0] * deepestLever[0] + deepestLever[1] * deepestLever[1] + deepestLever[2] * deepestLever[2]) - iVar4 * iVar4) * car_cosmetics[cp->ap.model].twistRateY) + 4096; iVar13 = 2; impulse = ((FixFloorSigned(reaction[0], 6) * FixFloorSigned(deepestNormal[0], 6) + FixFloorSigned(reaction[1], 6) * FixFloorSigned(deepestNormal[1], 6) + FixFloorSigned(reaction[2], 6) * FixFloorSigned(deepestNormal[2], 6)) / iVar4) * -2048; @@ -399,7 +399,7 @@ void StepOneCar(_CAR_DATA *cp) iVar6 = iVar1; } - *piVar11-- = FIXED(impulse * *piVar10 - iVar6); + *piVar11-- = FIXEDH(impulse * *piVar10 - iVar6); piVar10--; piVar9--; piVar8++; // [A] ASan bug fix @@ -436,15 +436,15 @@ void StepOneCar(_CAR_DATA *cp) cp->hd.acc[1] += direction.vy; cp->hd.acc[2] += direction.vz; - cp->hd.aacc[0] += FIXED(deepestLever[1] * direction.vz - deepestLever[2] * direction.vy); - cp->hd.aacc[1] += FIXED(deepestLever[2] * direction.vx - deepestLever[0] * direction.vz); - cp->hd.aacc[2] += FIXED(deepestLever[0] * direction.vy - deepestLever[1] * direction.vx); + cp->hd.aacc[0] += FIXEDH(deepestLever[1] * direction.vz - deepestLever[2] * direction.vy); + cp->hd.aacc[1] += FIXEDH(deepestLever[2] * direction.vx - deepestLever[0] * direction.vz); + cp->hd.aacc[2] += FIXEDH(deepestLever[0] * direction.vy - deepestLever[1] * direction.vx); if (iVar12 != 0) { - reaction[0] = FIXED(iVar12 * deepestNormal[0]); - reaction[1] = FIXED(iVar12 * deepestNormal[1]); - reaction[2] = FIXED(iVar12 * deepestNormal[2]); + reaction[0] = FIXEDH(iVar12 * deepestNormal[0]); + reaction[1] = FIXEDH(iVar12 * deepestNormal[1]); + reaction[2] = FIXEDH(iVar12 * deepestNormal[2]); cp->hd.where.t[0] += reaction[0]; cp->hd.where.t[1] += reaction[1]; @@ -626,8 +626,8 @@ void GetFrictionScalesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl, int *frontFS, int * if (traction != 0x1000) { - *frontFS = FIXED(*frontFS * traction); - *rearFS = FIXED(*rearFS * traction); + *frontFS = FIXEDH(*frontFS * traction); + *rearFS = FIXEDH(*rearFS * traction); } } @@ -683,11 +683,11 @@ void ConvertTorqueToAngularAcceleration(_CAR_DATA *cp, CAR_LOCALS *cl) i = 0; - zd = FIXED(cp->hd.where.m[0][2] * cp->hd.aacc[0] + cp->hd.where.m[1][2] * cp->hd.aacc[1] + cp->hd.where.m[2][2] * cp->hd.aacc[2]); + zd = FIXEDH(cp->hd.where.m[0][2] * cp->hd.aacc[0] + cp->hd.where.m[1][2] * cp->hd.aacc[1] + cp->hd.where.m[2][2] * cp->hd.aacc[2]); do { - cp->hd.aacc[i] = cp->hd.aacc[i] * twistY + FIXED(cp->hd.where.m[i][2] * (twistZ - twistY) * zd - cl->avel[i] * 128); + cp->hd.aacc[i] = cp->hd.aacc[i] * twistY + FIXEDH(cp->hd.where.m[i][2] * (twistZ - twistY) * zd - cl->avel[i] * 128); if (cl->extraangulardamping == 1) cp->hd.aacc[i] -= FixFloorSigned(cl->avel[i], 3); @@ -928,7 +928,7 @@ void AddWheelForcesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl) } oldCompression = wheel->susCompression; - newCompression = FIXED((surfacePoint[1] - wheelPos[1]) * surfaceNormal[1]) + 14; + newCompression = FIXEDH((surfacePoint[1] - wheelPos[1]) * surfaceNormal[1]) + 14; if (newCompression < 0) newCompression = 0; @@ -980,8 +980,8 @@ void AddWheelForcesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl) force.vz = 0; force.vx = 0; - pointVel[0] = FIXED(cl->avel[1] * wheelPos[2] - cl->avel[2] * wheelPos[1]) + cl->vel[0]; - pointVel[2] = FIXED(cl->avel[0] * wheelPos[1] - cl->avel[1] * wheelPos[0]) + cl->vel[2]; + pointVel[0] = FIXEDH(cl->avel[1] * wheelPos[2] - cl->avel[2] * wheelPos[1]) + cl->vel[0]; + pointVel[2] = FIXEDH(cl->avel[0] * wheelPos[1] - cl->avel[1] * wheelPos[0]) + cl->vel[2]; susForce = newCompression * 230 - oldCompression * 100; @@ -1038,7 +1038,7 @@ void AddWheelForcesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl) } else { - local_t0_1700 = FIXED(oldSpeed * iVar9); + local_t0_1700 = FIXEDH(oldSpeed * iVar9); if (12500 < local_t0_1700) goto LAB_000825f4; @@ -1067,7 +1067,7 @@ void AddWheelForcesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl) else { sidevel = (local_v0_1748 >> 0xd) + sidevel >> 1; - local_v0_1852 = FixFloorSigned(FIXED(-sidevel * lfx) * sdz - FIXED(-sidevel * lfz) * sdx, 11); + local_v0_1852 = FixFloorSigned(FIXEDH(-sidevel * lfx) * sdz - FIXEDH(-sidevel * lfz) * sdx, 11); force.vx = local_v0_1852 * sdz; force.vz = -local_v0_1852 * sdx; } @@ -1080,7 +1080,7 @@ void AddWheelForcesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl) { if (wheel->locked == 0) { - sidevel = FIXED(rearFS * local_t0_1700); + sidevel = FIXEDH(rearFS * local_t0_1700); if (handlingType[cp->hndType].autoBrakeOn != 0 && 0 < sidevel * cp->wheel_angle) cp->hd.autoBrake = -1; @@ -1113,19 +1113,19 @@ void AddWheelForcesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl) angle = 0x1000 - angle; if (angle < 0x1001) - _angle = 0x1000 - FIXED(angle * angle); + _angle = 0x1000 - FIXEDH(angle * angle); else _angle = 0; - friction_coef = FIXED(friction_coef * _angle); + friction_coef = FIXEDH(friction_coef * _angle); } if (surfaceNormal[1] < 0xccc) friction_coef = friction_coef * surfaceNormal[1] * 5 >> 0xe; - force.vy = FIXED(susForce * surfaceNormal[1] - cl->vel[1] * 12); - force.vx = FIXED(force.vx) * friction_coef >> 0xc; - force.vz = FIXED(force.vz) * friction_coef >> 0xc; + force.vy = FIXEDH(susForce * surfaceNormal[1] - cl->vel[1] * 12); + force.vx = FIXEDH(force.vx) * friction_coef >> 0xc; + force.vz = FIXEDH(force.vz) * friction_coef >> 0xc; if (cp->controlType == 3) { @@ -1138,9 +1138,9 @@ void AddWheelForcesDriver1(_CAR_DATA *cp, CAR_LOCALS *cl) cp->hd.acc[0] += force.vx; cp->hd.acc[1] += force.vy; cp->hd.acc[2] += force.vz; - cp->hd.aacc[0] += FIXED(wheelPos[1] * force.vz - wheelPos[2] * force.vy); - cp->hd.aacc[1] += FIXED(wheelPos[2] * force.vx - wheelPos[0] * force.vz); - cp->hd.aacc[2] += FIXED(wheelPos[0] * force.vy - wheelPos[1] * force.vx); + cp->hd.aacc[0] += FIXEDH(wheelPos[1] * force.vz - wheelPos[2] * force.vy); + cp->hd.aacc[1] += FIXEDH(wheelPos[2] * force.vx - wheelPos[0] * force.vz); + cp->hd.aacc[2] += FIXEDH(wheelPos[0] * force.vy - wheelPos[1] * force.vx); wheel->susCompression = newCompression; } diff --git a/src_rebuild/GAME/DR2MATH.H b/src_rebuild/GAME/DR2MATH.H index e9f4f5a3..5fa59746 100644 --- a/src_rebuild/GAME/DR2MATH.H +++ b/src_rebuild/GAME/DR2MATH.H @@ -19,10 +19,11 @@ #else -#define FixHalfRound(x, bits) (int(x) + (1 << (bits-1)) >> bits) -#define FixFloorSigned(x, bits) ((int(x) < 0 ? int(x) + (1 << bits)-1 : int(x)) >> bits) +#define FixHalfRound(x, bits) ((x) + (1 << (bits-1)) >> bits) +#define FixFloorSigned(x, bits) ((x) / (1 << bits)) // in disassembly: ((int(x) < 0 ? int(x) + (1 << bits)-1 : int(x)) >> bits) -#define FIXED(a) FixHalfRound(a, ONE_BITS) +#define FIXEDH(a) FixHalfRound(a, ONE_BITS) // Fixed Half Round number +#define FIXED(a) ((a) >> ONE_BITS) // Fixed number (unsigned) #endif