Merge pull request #22 from SoapyMan/develop-SoapyMan

Develop soapy man
This commit is contained in:
Ilya 2020-09-04 11:48:37 +06:00 committed by GitHub
commit 822896189a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 762 additions and 942 deletions

View File

@ -6,13 +6,13 @@
// ASM functions. // ASM functions.
// don't do this in PSX. // don't do this in PSX.
// [D] // [D] [T]
void SetCameraVector(void) void SetCameraVector(void)
{ {
gte_ldfc(&camera_position) gte_ldfc(&camera_position)
} }
// [D] // [D] [T]
void Apply_Inv_CameraMatrix(VECTOR *v) void Apply_Inv_CameraMatrix(VECTOR *v)
{ {
gte_ldlvl(v); gte_ldlvl(v);
@ -20,6 +20,7 @@ void Apply_Inv_CameraMatrix(VECTOR *v)
gte_stlvl(v); gte_stlvl(v);
} }
// [D] [T]
int Apply_InvCameraMatrixSetTrans(VECTOR_NOPAD *pos) int Apply_InvCameraMatrixSetTrans(VECTOR_NOPAD *pos)
{ {
VECTOR vfc; VECTOR vfc;
@ -44,6 +45,7 @@ int Apply_InvCameraMatrixSetTrans(VECTOR_NOPAD *pos)
return vec.vz + vec.vx; return vec.vz + vec.vx;
} }
// [D] [T]
int Apply_InvCameraMatrixAndSetMatrix(VECTOR_NOPAD *pos, MATRIX2 *mtx) int Apply_InvCameraMatrixAndSetMatrix(VECTOR_NOPAD *pos, MATRIX2 *mtx)
{ {
VECTOR vfc; VECTOR vfc;
@ -72,7 +74,7 @@ int Apply_InvCameraMatrixAndSetMatrix(VECTOR_NOPAD *pos, MATRIX2 *mtx)
extern MATRIX frustrum_matrix; extern MATRIX frustrum_matrix;
// [D] // [D] [T]
int FrustrumCheck16(PACKED_CELL_OBJECT *pcop, int bounding_sphere) int FrustrumCheck16(PACKED_CELL_OBJECT *pcop, int bounding_sphere)
{ {
VECTOR local; VECTOR local;
@ -95,7 +97,7 @@ int FrustrumCheck16(PACKED_CELL_OBJECT *pcop, int bounding_sphere)
return -1; return -1;
} }
// [D] // [D] [T]
int FrustrumCheck(VECTOR *pos, int bounding_sphere) int FrustrumCheck(VECTOR *pos, int bounding_sphere)
{ {
VECTOR local; VECTOR local;

View File

@ -28,7 +28,7 @@
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void StoreGameFlags(void) void StoreGameFlags(void)
{ {
ReplayParameterPtr->weather = gWeather; ReplayParameterPtr->weather = gWeather;
@ -68,11 +68,11 @@ void StoreGameFlags(void)
/* end block 3 */ /* end block 3 */
// End Line: 661 // End Line: 661
// [D] // [D] [T]
int TannerCanEnterCar(_CAR_DATA *cp, int distToCarSq) int TannerCanEnterCar(_CAR_DATA *cp, int distToCarSq)
{ {
int iVar1; int speed;
int iVar2; int carRange;
if ((cp->controlFlags & 1) != 0) if ((cp->controlFlags & 1) != 0)
gCopCarTheftAttempted = 1; gCopCarTheftAttempted = 1;
@ -83,20 +83,20 @@ int TannerCanEnterCar(_CAR_DATA *cp, int distToCarSq)
(cp->controlFlags & 2) == 0 && (cp->controlFlags & 2) == 0 &&
cp->hd.where.m[1][1] > 99) // not flipped over cp->hd.where.m[1][1] > 99) // not flipped over
{ {
iVar1 = FIXED(cp->hd.wheel_speed); speed = FIXED(cp->hd.wheel_speed);
if (iVar1 < 0) if (speed < 0)
iVar1 = -iVar1; speed = -speed;
if (iVar1 < 3) if (speed < 3)
{ {
iVar1 = car_cosmetics[cp->ap.model].colBox.vx * 2; carRange = car_cosmetics[cp->ap.model].colBox.vx * 2;
iVar2 = iVar1 * iVar1; carRange *= carRange;
if (5000 < iVar1) if (5000 < carRange)
iVar2 = 25000000; carRange = 25000000;
return (iVar2 < distToCarSq) ^ 1; return (carRange < distToCarSq) ^ 1;
} }
} }
@ -132,7 +132,7 @@ int TannerCanEnterCar(_CAR_DATA *cp, int distToCarSq)
int TannerStuckInCar(int doSpeedCheck, int player_id) int TannerStuckInCar(int doSpeedCheck, int player_id)
{ {
short *psVar1; short *psVar1;
int iVar2; int speed;
int iVar3; int iVar3;
_CAR_DATA *cp; _CAR_DATA *cp;
@ -160,12 +160,12 @@ int TannerStuckInCar(int doSpeedCheck, int player_id)
{ {
if (doSpeedCheck != 0) if (doSpeedCheck != 0)
{ {
iVar2 = FIXED(cp->hd.wheel_speed); speed = FIXED(cp->hd.wheel_speed);
if (iVar2 < 0) if (speed < 0)
iVar2 = -iVar2; speed = -speed;
if (2 < iVar2) if (speed > 2)
return 1; return 1;
} }
@ -177,9 +177,4 @@ int TannerStuckInCar(int doSpeedCheck, int player_id)
} }
return 1; return 1;
} }

View File

@ -33,18 +33,13 @@
/* end block 2 */ /* end block 2 */
// End Line: 167 // End Line: 167
// [D] // [D] [T]
void PointFaceCheck(_CAR_DATA *cp0, _CAR_DATA *cp1, int i, TestResult *least, int nSign) void PointFaceCheck(_CAR_DATA *cp0, _CAR_DATA *cp1, int i, TestResult *least, int nSign)
{ {
int iVar1; int partialDepth;
//short *psVar2; int depth;
int iVar3; SVECTOR_NOPAD *radii;
int iVar4; int k;
int iVar5;
int iVar6;
//short *psVar7;
SVECTOR_NOPAD *pSVar8;
int iVar9;
VECTOR normal; VECTOR normal;
VECTOR diff; VECTOR diff;
@ -62,9 +57,9 @@ void PointFaceCheck(_CAR_DATA *cp0, _CAR_DATA *cp1, int i, TestResult *least, in
diff.vy = point.vy - cp0->hd.oBox.location.vy; diff.vy = point.vy - cp0->hd.oBox.location.vy;
diff.vz = point.vz - cp0->hd.oBox.location.vz; diff.vz = point.vz - cp0->hd.oBox.location.vz;
iVar4 = FIXED(diff.vx * normal.vx + diff.vy * normal.vy + diff.vz * normal.vz); depth = FIXED(diff.vx * normal.vx + diff.vy * normal.vy + diff.vz * normal.vz);
if (iVar4 < 0) if (depth < 0)
{ {
normal.vx = -normal.vx; normal.vx = -normal.vx;
normal.vy = -normal.vy; normal.vy = -normal.vy;
@ -72,43 +67,43 @@ void PointFaceCheck(_CAR_DATA *cp0, _CAR_DATA *cp1, int i, TestResult *least, in
} }
else else
{ {
iVar4 = -iVar4; depth = -depth;
} }
pSVar8 = cp1->hd.oBox.radii; radii = cp1->hd.oBox.radii;
iVar4 += cp0->hd.oBox.length[i]; depth += cp0->hd.oBox.length[i];
iVar9 = 2; k = 2;
do { do {
iVar3 = pSVar8->vx; diff.vx = radii->vx;
iVar5 = pSVar8->vy; diff.vy = radii->vy;
iVar6 = pSVar8->vz; diff.vz = radii->vz;
iVar1 = FIXED(iVar3 * normal.vx + iVar5 * normal.vy + iVar6 * normal.vz); partialDepth = FIXED(diff.vx * normal.vx + diff.vy * normal.vy + diff.vz * normal.vz);
if (iVar1 < 0) if (partialDepth < 0)
{ {
iVar1 = -iVar1; partialDepth = -partialDepth;
} }
else else
{ {
iVar3 = -iVar3; diff.vx = -diff.vx;
iVar5 = -iVar5; diff.vy = -diff.vy;
iVar6 = -iVar6; diff.vz = -diff.vz;
} }
point.vy += iVar5; point.vx += diff.vx;
point.vx += iVar3; point.vy += diff.vy;
point.vz += iVar6; point.vz += diff.vz;
iVar4 += iVar1; depth += partialDepth;
pSVar8++; radii++;
iVar9--; k--;
} while (-1 < iVar9); } while (k >= 0);
if (iVar4 < least->depth && (least->depth = iVar4, -1 < iVar4)) if (depth < least->depth && (least->depth = depth, -1 < depth))
{ {
least->location.vx = point.vx; least->location.vx = point.vx;
least->location.vy = point.vy; least->location.vy = point.vy;
@ -152,7 +147,7 @@ void PointFaceCheck(_CAR_DATA *cp0, _CAR_DATA *cp1, int i, TestResult *least, in
/* end block 3 */ /* end block 3 */
// End Line: 267 // End Line: 267
// [D] // [D] [T]
int collided3d(_CAR_DATA *cp0, _CAR_DATA *cp1, TestResult *least) int collided3d(_CAR_DATA *cp0, _CAR_DATA *cp1, TestResult *least)
{ {
int i; int i;
@ -209,7 +204,7 @@ int collided3d(_CAR_DATA *cp0, _CAR_DATA *cp1, TestResult *least)
/* end block 3 */ /* end block 3 */
// End Line: 361 // End Line: 361
// [D] // [D] [T]
int CarCarCollision3(_CAR_DATA *c0, _CAR_DATA *c1, int *depth, VECTOR *where, VECTOR *normal) int CarCarCollision3(_CAR_DATA *c0, _CAR_DATA *c1, int *depth, VECTOR *where, VECTOR *normal)
{ {
int res; int res;

View File

@ -59,179 +59,128 @@
int boxOverlap = 0; int boxOverlap = 0;
// Checks of two bodies collides (basic check) // Checks of two bodies collides (basic check) with Separating Axis Theorem
// also initializes axes // also initializes axes
// [D] [A] // [D] [T]
int bcollided2d(CDATA2D *body, int needOverlap) int bcollided2d(CDATA2D *body, int needOverlap)
{ {
int dtheta;
int absdist;
int abslim;
short ac; short ac;
short as; short as;
short sVar3; int i; // $t7
short sVar4; int j; // $a2
int dtheta; int k; // $t5
int iVar6;
int iVar7;
int iVar8;
int iVar9;
int *piVar10;
CDATA2D *pCVar11;
VECTOR *pVVar12;
int *piVar13;
int *piVar14;
int *piVar15;
int *piVar16;
int *piVar17;
int iVar18;
int iVar19;
int uVar20;
VECTOR *pVVar21;
int *plVar22;
int *piVar23;
int iVar24;
int *piVar25;
VECTOR delta; VECTOR delta;
int xover; // $t0
int zover; // $a0
int tmp2; // $a2
int FE; // $a3
iVar19 = 1;
pCVar11 = body + 1;
dtheta = body[1].theta - body[0].theta; dtheta = body[1].theta - body[0].theta;
// calc axes of each box
i = 1;
do {
as = rcossin_tbl[(body[i].theta & 0xfff) * 2];
ac = rcossin_tbl[(body[i].theta & 0xfff) * 2 + 1];
body[i].axis[0].vx = as;
body[i].axis[0].vz = ac;
body[i].axis[1].vz = -as;
body[i].axis[1].vx = ac;
i--;
} while (i != -1);
ac = rcossin_tbl[(dtheta + 0x400 & 0x7ff) * 2]; ac = rcossin_tbl[(dtheta + 0x400 & 0x7ff) * 2];
as = rcossin_tbl[(dtheta & 0x7ff) * 2]; as = rcossin_tbl[(dtheta & 0x7ff) * 2];
// calc axes of each box
do {
dtheta = body[iVar19].theta & 0xfff;
sVar3 = rcossin_tbl[dtheta * 2];
sVar4 = rcossin_tbl[dtheta * 2 + 1];
body[iVar19].axis[0].vx = sVar3;
body[iVar19].axis[0].vz = sVar4;
body[iVar19].axis[1].vz = -sVar3;
body[iVar19].axis[1].vx = sVar4;
iVar19--;
} while (iVar19 != -1);
dtheta = 0;
uVar20 = 1;
piVar23 = body[1].limit;
piVar25 = body[1].dist;
iVar24 = 100;
delta.vx = body[0].x.vx - body[1].x.vx; delta.vx = body[0].x.vx - body[1].x.vx;
delta.vz = body[0].x.vz - body[1].x.vz; delta.vz = body[0].x.vz - body[1].x.vz;
k = 0;
i = 1;
do { do {
j = 1;
piVar15 = piVar23 + 1;
piVar10 = piVar25 + 1;
piVar17 = body[uVar20].length + 1;
piVar16 = body[dtheta].length + 1;
piVar14 = body[dtheta].length;
pVVar12 = body[uVar20].axis + 1;
iVar18 = 1;
do { do {
*piVar10 = FIXED(pVVar12->vx * delta.vx + pVVar12->vz * delta.vz); body[i].dist[j] = FIXED(body[i].axis[j].vx * delta.vx + body[i].axis[j].vz * delta.vz);
iVar7 = *piVar17 + FIXED(*piVar16 * ac + *piVar14 * as); body[i].limit[j] = body[i].length[j] + FIXED(body[k].length[j] * ac + body[k].length[1-j] * as);
*piVar15 = iVar7;
if (iVar7 < *piVar10) if (body[i].limit[j] < body[i].dist[j])
return 0; return 0;
if (*piVar10 < -iVar7) if (body[i].dist[j] < -body[i].limit[j])
return 0; return 0;
piVar15--; j--;
piVar10--; } while (j != -1);
piVar17--; k = i & 1;
piVar16--;
i--;
if (i == -1)
pVVar12--;
iVar18--;
piVar14++;
} while (iVar18 != -1);
dtheta = uVar20 & 1;
piVar23 -= 25;
piVar25 = piVar25 - 25;
iVar24 -= 100;
uVar20--;
if (uVar20 == -1)
{ {
if (needOverlap != 0) if (needOverlap != 0)
{ {
iVar19 = body[1].dist[0]; absdist = body[1].dist[0];
iVar6 = body[1].limit[0];
if (iVar19 < 0) if (absdist < 0)
iVar19 = -iVar19; absdist = -absdist;
if (iVar6 < 0) abslim = body[1].limit[0];
iVar6 = -iVar6; if (abslim < 0)
abslim = -abslim;
iVar8 = iVar19 - iVar6; FE = absdist - abslim;
if (iVar8 < 0) if (FE < 0)
iVar8 = iVar6 - iVar19; FE = abslim - absdist;
iVar9 = body[0].axis[0].vx; tmp2 = FIXED(body->axis[0].vx * body[1].axis[0].vx + body->axis[0].vz * body[1].axis[0].vz);
iVar6 = body[0].axis[0].vz; if (tmp2 < 0)
tmp2 = -tmp2;
iVar19 = FIXED(iVar9 * body[1].axis[0].vx + iVar6 * body[1].axis[0].vz); if (tmp2 < 11)
xover = -1;
else
xover = (FE << 0xc) / tmp2;
if (iVar19 < 0) absdist = body[1].dist[1];
iVar19 = -iVar19;
if (absdist < 0)
absdist = -absdist;
if (iVar19 < 11) abslim = body[1].limit[1];
iVar8 = -1; if (abslim < 0)
else abslim = -abslim;
iVar8 = (iVar8 * 4096) / iVar19;
FE = absdist - abslim;
iVar19 = body[1].dist[1]; if (FE < 0)
iVar24 = body[1].limit[1]; FE = abslim - absdist;
if (iVar19 < 0) tmp2 = FIXED(body->axis[0].vx * body[1].axis[1].vx + body->axis[0].vz * body[1].axis[1].vz);
iVar19 = -iVar19;
if (iVar24 < 0) if (tmp2 < 0)
iVar24 = -iVar24; tmp2 = -tmp2;
iVar18 = iVar19 - iVar24; zover = xover;
if (iVar18 < 0) if (10 < tmp2)
iVar18 = iVar24 - iVar19; zover = (FE << 0xc) / tmp2;
iVar19 = FIXED(iVar9 * body[1].axis[1].vx + iVar6 * body[1].axis[1].vz); if (xover > -1)
if (iVar19 < 0)
iVar19 = -iVar19;
iVar6 = iVar8;
if (10 < iVar19)
iVar6 = (iVar18 * 4096) / iVar19;
boxOverlap = iVar6;
if (-1 < iVar8)
{ {
boxOverlap = iVar8; if (zover < xover)
boxOverlap = zover;
if (iVar6 < iVar8) else
boxOverlap = iVar6; boxOverlap = xover;
} }
else
boxOverlap = zover;
} }
return 1; return 1;
} }
@ -300,141 +249,107 @@ int bcollided2d(CDATA2D *body, int needOverlap)
/* end block 4 */ /* end block 4 */
// End Line: 432 // End Line: 432
// [D] // [D] [T]
void bFindCollisionPoint(CDATA2D *body, CRET2D *collisionResult) void bFindCollisionPoint(CDATA2D *body, CRET2D *collisionResult)
{ {
bool bVar1; bool carBarrierCollision;
int iVar2; int lower;
int iVar3; int upper;
int iVar4; int sign1;
int iVar5; int k;
int *piVar6; int _k;
CDATA2D *pCVar7; int sign0;
uint uVar8; int sign;
int *piVar9; int smallest;
int iVar10; int besti;
int iVar11; int bestk;
int local_t1_132; CDATA2D* cd;
int *piVar12; int i;
int *piVar13;
int iVar14;
int iVar15;
int local_t5_4;
VECTOR *pVVar16;
int iVar17;
local_t5_4 = 0; besti = 0;
iVar17 = 0; bestk = 0;
iVar14 = 0; sign = 0;
bVar1 = false; carBarrierCollision = false;
iVar15 = body->limit[0] + 1;
if ((body->isCameraOrTanner == 0) && (body[1].isCameraOrTanner == 0)) smallest = body->limit[0] + 1;
if ((body->isCameraOrTanner == 0) && (body[1].isCameraOrTanner == 0) &&
(body[1].length[0] << 3 <= body[1].length[1]) || (body[1].length[1] << 3 <= body[1].length[0]))
{ {
if ((body[1].length[0] << 2 <= body[1].length[1]) || carBarrierCollision = true;
(body[1].length[1] << 2 <= body[1].length[0]))
{
bVar1 = true;
}
} }
uVar8 = 1; i = 1;
do { do {
iVar11 = 1; k = 1;
local_t1_132 = uVar8 - 1;
piVar6 = body[uVar8].dist + 1;
do { do {
iVar5 = piVar6[2] - *piVar6; upper = body[i].limit[k] - body[i].dist[k];
iVar2 = *piVar6 + piVar6[2]; lower = body[i].dist[k] + body[i].limit[k];
if ((iVar5 < iVar15) && if (upper < smallest && (sign = -1, smallest = upper, besti = i, bestk = k, i == 1))
(iVar14 = -1, iVar15 = iVar5, local_t5_4 = uVar8, iVar17 = iVar11, uVar8 == 1)) { {
iVar14 = 1; sign = 1;
} }
if ((iVar2 < iVar15) && if (lower < smallest && (sign = 1, smallest = lower, besti = i, bestk = k, i == 1))
(iVar14 = 1, iVar15 = iVar2, local_t5_4 = uVar8, iVar17 = iVar11, uVar8 == 1)) { {
iVar14 = -1; sign = -1;
} }
iVar11--; k--;
piVar6--; } while (k != -1);
} while (iVar11 != -1);
iVar11 = 1;
uVar8 = local_t1_132; i--;
} while (local_t1_132 != -1); } while (i != -1);
if (bVar1) if (carBarrierCollision)
{ {
piVar9 = body[1].length + 1; k = 1;
piVar6 = body[1].length;
piVar13 = body[1].dist + 1;
piVar12 = body[1].limit + 1;
do { do {
iVar5 = *piVar12 - *piVar13; upper = body[1].limit[k] - body[1].dist[k];
iVar2 = *piVar13 + *piVar12; lower = body[1].dist[k] + body[1].limit[k];
if ((iVar5 < iVar2) && (*piVar9 < *piVar6 << 2)) if (upper < lower && (body[1].length[k] < body[1].length[1-k] << 2))
{ {
local_t5_4 = 1; besti = 1;
iVar14 = 1; sign = 1;
iVar17 = iVar11; bestk = k;
} }
if ((iVar2 < iVar5) && (*piVar9 < *piVar6 << 2)) if (lower < upper && (body[1].length[k] < body[1].length[1 - k] << 2))
{ {
local_t5_4 = 1; besti = 1;
iVar14 = -1; sign = -1;
iVar17 = iVar11; bestk = k;
} }
piVar9--; k--;
piVar6++; } while (k != -1);
piVar13--;
iVar11--;
piVar12--;
} while (iVar11 != -1);
} }
pCVar7 = body + (local_t5_4 ^ 1); cd = &body[(besti ^ 1)];
pVVar16 = body[local_t5_4].axis + iVar17;
iVar5 = pCVar7->axis[0].vx;
iVar2 = pVVar16->vx;
piVar6 = (int*)&body[local_t5_4].axis[iVar17].vz;
iVar11 = body[local_t5_4].axis[iVar17].vz;
iVar17 = iVar14;
if (-1 < iVar5 * iVar2 + pCVar7->axis[0].vz * iVar11) sign0 = sign;
iVar17 = -iVar14; if (-1 < cd->axis[0].vx * body[besti].axis[bestk].vx + cd->axis[0].vz * body[besti].axis[bestk].vz + 0x800)
sign0 = -sign;
iVar3 = pCVar7->axis[1].vx; sign1 = sign;
iVar10 = iVar14;
if (-1 < iVar3 * iVar2 + pCVar7->axis[1].vz * iVar11) if (-1 < cd->axis[1].vx * body[besti].axis[bestk].vx + cd->axis[1].vz * body[besti].axis[bestk].vz + 0x800)
iVar10 = -iVar14; sign1 = -sign;
collisionResult->hit.vx = pCVar7->x.vx + FIXED(iVar5 * pCVar7->length[0] * iVar17 + iVar3 * pCVar7->length[1] * iVar10); collisionResult->penetration = smallest;
iVar11 = pCVar7->axis[0].vz; collisionResult->hit.vx = cd->x.vx + FIXED(cd->axis[0].vx * cd->length[0] * sign0 + cd->axis[1].vx * cd->length[1] * sign1);
iVar2 = pCVar7->length[0]; collisionResult->hit.vz = cd->x.vz + FIXED(cd->axis[0].vz * cd->length[0] * sign0 + cd->axis[1].vz * cd->length[1] * sign1);
iVar4 = pCVar7->axis[1].vz;
iVar5 = pCVar7->length[1];
iVar3 = pCVar7->x.vz;
collisionResult->penetration = iVar15; if (besti != 0)
collisionResult->hit.vz = pCVar7->x.vz + FIXED(iVar11 * iVar2 * iVar17 + iVar4 * iVar5 * iVar10); sign = -sign;
if (local_t5_4 != 0)
iVar14 = -iVar14;
iVar15 = pVVar16->vx;
collisionResult->surfNormal.vy = 0; collisionResult->surfNormal.vy = 0;
collisionResult->surfNormal.vx = iVar15 * iVar14; collisionResult->surfNormal.vx = body[besti].axis[bestk].vx * sign;
collisionResult->surfNormal.vz = *piVar6 * iVar14; collisionResult->surfNormal.vz = body[besti].axis[bestk].vz * sign;
} }
@ -468,151 +383,121 @@ void bFindCollisionPoint(CDATA2D *body, CRET2D *collisionResult)
/* end block 3 */ /* end block 3 */
// End Line: 639 // End Line: 639
// [D] // [D] [T]
int bFindCollisionTime(CDATA2D *cd, CRET2D *collisionResult) int bFindCollisionTime(CDATA2D *cd, CRET2D *collisionResult)
{ {
int *piVar1; CDATA2D* coll;
VECTOR *pVVar2; int hit;
int iVar3; int q;
long lVar4; int time;
CDATA2D *pCVar5; int step;
int *local_a1_184; int i;
int iVar6; int neverfree;
int *piVar7;
int *piVar8;
int iVar9;
int iVar10;
int iVar11;
int iVar12;
int iVar13;
CDATA2D *pCVar14;
long *plVar15;
int iVar16;
int iVar17;
int iVar18;
CDATA2D original[2]; CDATA2D original[2];
iVar11 = 1; hit = 1;
iVar18 = 1; neverfree = 1;
iVar13 = 0x1000; time = 0x1000;
iVar16 = 0x800; step = 0x800;
iVar17 = 1;
pCVar5 = cd + 1; i = 1;
iVar10 = 100;
do { do {
original[iVar17].x.vx = cd[iVar17].x.vx; original[i].dist[0] = cd[i].dist[0];
original[iVar17].x.vz = cd[iVar17].x.vz; original[i].limit[0] = cd[i].limit[0];
original[iVar17].theta = cd[iVar17].theta; original[i].dist[1] = cd[i].dist[1];
original[i].limit[1] = cd[i].limit[1];
original[i].axis[0] = cd[i].axis[0];
original[i].axis[1] = cd[i].axis[1];
original[iVar17].dist[0] = cd[iVar17].dist[0]; original[i].x = cd[i].x;
original[iVar17].limit[0] = cd[iVar17].limit[0]; original[i].theta = cd[i].theta;
original[iVar17].dist[1] = cd[iVar17].dist[1];
original[iVar17].limit[1] = cd[iVar17].limit[1];
iVar17--;
} while (iVar17 != -1); i--;
iVar10 = 7; } while (i != -1);
i = 7;
do { do {
iVar12 = 1;
iVar17 = iVar10 + -1; coll = cd + 1;
pCVar5 = cd + 1; q = 1;
do do {
{ coll->vel.vx >>= 1;
iVar6 = pCVar5->vel.vx / 2; coll->vel.vz >>= 1;
iVar3 = pCVar5->vel.vz; coll->avel >>= 1;
iVar9 = pCVar5->avel / 2; if (hit == 0)
pCVar5->vel.vx = iVar6;
pCVar5->avel = iVar9;
iVar3 = iVar3 >> 1;
pCVar5->vel.vz = iVar3;
if (iVar11 == 0)
{ {
pCVar5->x.vx += iVar6; coll->x.vx += coll->vel.vx;
pCVar5->x.vz += iVar3; coll->x.vz += coll->vel.vz;
coll->theta += coll->avel;
iVar6 = pCVar5->theta + iVar9;
} }
else else
{ {
pCVar5->x.vx -= iVar6; coll->x.vx -= coll->vel.vx;
pCVar5->x.vz -= iVar3; coll->x.vz -= coll->vel.vz;
iVar6 = pCVar5->theta - iVar9; coll->theta -= coll->avel;
} }
pCVar5->theta = iVar6; q--;
iVar12--; coll--;
pCVar5--; } while (q != -1);
} while (iVar12 != -1);
if (iVar11 == 0) if (hit == 0)
{ {
iVar18 = 0; neverfree = 0;
iVar11 = iVar16; time += step;
} }
else else
{ {
iVar11 = -iVar16; time -= step;
} }
iVar13 = iVar13 + iVar11; hit = bcollided2d(cd, 0);
iVar11 = bcollided2d(cd, 0); if (i != 0)
step >> 1;
if (iVar10 != 0) i--;
iVar16 = iVar16 >> 1; } while (i != -1);
iVar12 = 1; if (hit == 0)
iVar10 = iVar17;
} while (iVar17 != -1);
if (iVar11 == 0)
{ {
pCVar5 = cd + 1; i = 1;
coll = cd + 1;
do {
coll->x.vx += coll->vel.vx;
coll->x.vz += coll->vel.vz;
coll->theta += coll->avel;
do { coll--;
pCVar5->x.vx += pCVar5->vel.vx; i--;
pCVar5->x.vz += pCVar5->vel.vz; } while (i != -1);
pCVar5->theta += pCVar5->avel;
iVar12--;
pCVar5--;
} while (iVar12 != -1);
bcollided2d(cd, 0); bcollided2d(cd, 0);
iVar13 = iVar13 + iVar16; time += step;
} }
else else if (neverfree != 0)
{ {
iVar11 = 1; i = 1;
if (iVar18 != 0) coll = cd + 1;
{ do {
pCVar5 = cd + 1; coll->x.vx = original[i].x.vx;
pCVar14 = original + 1; coll->x.vz = original[i].x.vz;
coll->theta = original[i].theta;
do { bcollided2d(cd, 0);
pCVar5->x.vx = pCVar14->x.vx;
pCVar5->x.vz = pCVar14->x.vz;
pCVar5->theta = pCVar14->theta;
bcollided2d(cd, 0); coll--;
i--;
} while (i != -1);
pCVar14--; time = 0x1000;
pCVar5--;
iVar11--;
} while (iVar11 != -1);
iVar13 = 0x1000;
}
} }
collisionResult->neverfree = iVar18; collisionResult->neverfree = neverfree;
return iVar13;
return time;
} }
@ -640,17 +525,12 @@ int bFindCollisionTime(CDATA2D *cd, CRET2D *collisionResult)
/* end block 3 */ /* end block 3 */
// End Line: 994 // End Line: 994
// [D] // [D] [T]
void ApplyDamage(_CAR_DATA *cp, char region, int value, char fakeDamage) void ApplyDamage(_CAR_DATA *cp, char region, int value, char fakeDamage)
{ {
ushort uVar1; short *pRegion;
int iVar2;
int iVar3;
ushort *puVar4;
short *psVar5;
iVar3 = region; pRegion = (cp->ap.damage + region);
puVar4 = (ushort *)(cp->ap.damage + region);
if (cp->controlType == 1 || cp->controlType == 4) if (cp->controlType == 1 || cp->controlType == 4)
value = value * FIXED(gPlayerDamageFactor); value = value * FIXED(gPlayerDamageFactor);
@ -661,20 +541,14 @@ void ApplyDamage(_CAR_DATA *cp, char region, int value, char fakeDamage)
{ {
if (gCopDifficultyLevel == 1) if (gCopDifficultyLevel == 1)
{ {
iVar2 = value * 0xc; value = value * 12 >> 4;
} }
else else if (gCopDifficultyLevel == 2)
{ {
if (gCopDifficultyLevel != 2) value = value * 7 >> 4;
goto LAB_0001cf9c;
iVar2 = value * 7;
} }
value = iVar2 >> 4;
} }
LAB_0001cf9c:
if (fakeDamage == 0) if (fakeDamage == 0)
{ {
if (cp->totalDamage < 0xffff - value) if (cp->totalDamage < 0xffff - value)
@ -683,40 +557,39 @@ LAB_0001cf9c:
cp->totalDamage = 0xffff; cp->totalDamage = 0xffff;
} }
uVar1 = *puVar4; *pRegion += value;
*puVar4 = (uVar1 + value);
if (0xfff < ((uVar1 + value) * 0x10000) >> 0x10) if (*pRegion > 4095)
*puVar4 = 0xfff; *pRegion = 4095;
if (iVar3 == 1) // adjust symmetric regions
iVar3 = 0; if (region == 1)
else if (iVar3 == 0) region = 0;
iVar3 = 1; else if (region == 0)
else if (iVar3 == 3) region = 1;
iVar3 = 4; else if (region == 3)
else if (iVar3 == 4) region = 4;
iVar3 = 3; else if (region == 4)
region = 3;
else else
iVar3 = -1; region = -1;
if (region != -1)
if (iVar3 != -1)
{ {
psVar5 = cp->ap.damage + iVar3; pRegion = cp->ap.damage + region;
value = value >> 1; value >>= 1;
if (*psVar5 < value) if (*pRegion < value)
{ {
if (fakeDamage == 0) if (fakeDamage == 0)
{ {
if (cp->totalDamage < 0xffff - (value - *psVar5)) if (cp->totalDamage < 0xffff - (value - *pRegion))
cp->totalDamage += (value - *psVar5); cp->totalDamage += (value - *pRegion);
else else
cp->totalDamage = 0xffff; cp->totalDamage = 0xffff;
} }
*psVar5 = value; *pRegion = value;
} }
} }
} }
@ -763,16 +636,16 @@ LAB_0001cf9c:
/* end block 3 */ /* end block 3 */
// End Line: 1169 // End Line: 1169
// [D] // [D] [T]
int DamageCar3D(_CAR_DATA *cp, long(*delta)[4], int strikeVel, _CAR_DATA *pOtherCar) int DamageCar3D(_CAR_DATA *cp, long(*delta)[4], int strikeVel, _CAR_DATA *pOtherCar)
{ {
char region; char region;
int value; int value;
int iVar1;
bool fakeDamage; bool fakeDamage;
int player_id; int player_id;
int kludge; int kludge;
int door, nose;
strikeVel = strikeVel * 0x177; strikeVel = strikeVel * 0x177;
@ -789,20 +662,21 @@ int DamageCar3D(_CAR_DATA *cp, long(*delta)[4], int strikeVel, _CAR_DATA *pOther
return 0; return 0;
} }
iVar1 = 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]); 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]);
if (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]) < 1) if (door < 1)
{ {
region = 0; region = 0;
if ((iVar1 <= value) && (region = 4, -value < iVar1)) if ((nose <= value) && (region = 4, -value < nose))
region = 5; region = 5;
} }
else else
{ {
region = 1; region = 1;
if ((iVar1 <= value) && (region = 3, -value < iVar1)) if ((nose <= value) && (region = 3, -value < nose))
region = 2; region = 2;
} }
@ -842,8 +716,7 @@ int DamageCar3D(_CAR_DATA *cp, long(*delta)[4], int strikeVel, _CAR_DATA *pOther
} }
else else
{ {
iVar1 = (strikeVel / 400 + 0x400) * 7; value = ((strikeVel / 400 + 0x400) * 7) >> 3;
value = iVar1 >> 3;
} }
fakeDamage = cp->controlType == 3 && pOtherCar->controlType == 3; fakeDamage = cp->controlType == 3 && pOtherCar->controlType == 3;
@ -902,17 +775,20 @@ int DamageCar3D(_CAR_DATA *cp, long(*delta)[4], int strikeVel, _CAR_DATA *pOther
/* end block 3 */ /* end block 3 */
// End Line: 1442 // End Line: 1442
// [D] // [D] [T]
void DamageCar(_CAR_DATA *cp, CDATA2D *cd, CRET2D *collisionResult, int strikeVel) void DamageCar(_CAR_DATA *cp, CDATA2D *cd, CRET2D *collisionResult, int strikeVel)
{ {
int impact; int impact;
int iVar1; int player_id;
int value; int value;
int iVar2; int nose;
int iVar3; int door;
int iVar4; int region;
int dz;
int dx;
player_id = GetPlayerId(cp);
iVar1 = GetPlayerId(cp);
value = cp->ap.carCos->colBox.vz << 0x10; value = cp->ap.carCos->colBox.vz << 0x10;
impact = strikeVel / 600; impact = strikeVel / 600;
@ -920,22 +796,24 @@ void DamageCar(_CAR_DATA *cp, CDATA2D *cd, CRET2D *collisionResult, int strikeVe
if (0x4fff < strikeVel && 9 < cp->hd.speed) if (0x4fff < strikeVel && 9 < cp->hd.speed)
{ {
iVar4 = collisionResult->hit.vx - cd->x.vx; dx = collisionResult->hit.vx - cd->x.vx;
iVar3 = collisionResult->hit.vz - cd->x.vz; dz = collisionResult->hit.vz - cd->x.vz;
iVar2 = FIXED(cd->axis[0].vx * iVar4 + cd->axis[0].vz * iVar3); nose = FIXED(cd->axis[0].vx * dx + cd->axis[0].vz * dz);
door = FIXED(cd->axis[1].vx * dx + cd->axis[1].vz * dz);
if (FIXED(cd->axis[1].vx * iVar4 + cd->axis[1].vz * iVar3) < 1) if (door < 1)
{ {
iVar3 = 0; region = 0;
if ((iVar2 <= value) && (iVar3 = 4, -value < iVar2)) if ((nose <= value) && (region = 4, -value < nose))
iVar3 = 5; region = 5;
} }
else { else
iVar3 = 1; {
region = 1;
if ((iVar2 <= value) && (iVar3 = 3, -value < iVar2)) if ((nose <= value) && (region = 3, -value < nose))
iVar3 = 2; region = 2;
} }
if (0x1f4000 < strikeVel) if (0x1f4000 < strikeVel)
strikeVel = 0x1f4000; strikeVel = 0x1f4000;
@ -944,7 +822,7 @@ void DamageCar(_CAR_DATA *cp, CDATA2D *cd, CRET2D *collisionResult, int strikeVe
if (0x800 < value) if (0x800 < value)
value = 0x800; value = 0x800;
value -= (value * cp->ap.damage[iVar3] >> 0xd); value -= (value * cp->ap.damage[region] >> 0xd);
if (cp->controlType == 4) if (cp->controlType == 4)
{ {
@ -954,8 +832,8 @@ void DamageCar(_CAR_DATA *cp, CDATA2D *cd, CRET2D *collisionResult, int strikeVe
value = value / 2; value = value / 2;
} }
ApplyDamage(cp, iVar3, value, 0); ApplyDamage(cp, region, value, 0);
CollisionSound(iVar1, cp, impact, 0); CollisionSound(player_id, cp, impact, 0);
} }
} }

View File

@ -4168,7 +4168,7 @@ void DrawEvents(int camera)
} }
} }
else else
{ {
SetCamera(ev); SetCamera(ev);
DrawMapPSX((int*)&ObjectDrawnValue); DrawMapPSX((int*)&ObjectDrawnValue);
} }

View File

@ -58,7 +58,7 @@ CELL_OBJECT** coplist;
/* end block 3 */ /* end block 3 */
// End Line: 475 // End Line: 475
// [D] // [D] [T]
void NewProcessRoadMapLump(ROAD_MAP_LUMP_DATA *pRoadMapLumpData, char *pLumpFile) void NewProcessRoadMapLump(ROAD_MAP_LUMP_DATA *pRoadMapLumpData, char *pLumpFile)
{ {
Getlong((char*)&pRoadMapLumpData->width, pLumpFile); Getlong((char*)&pRoadMapLumpData->width, pLumpFile);
@ -83,7 +83,7 @@ void NewProcessRoadMapLump(ROAD_MAP_LUMP_DATA *pRoadMapLumpData, char *pLumpFile
/* end block 2 */ /* end block 2 */
// End Line: 1665 // End Line: 1665
// [D] // [D] [T]
void ProcessJunctionsLump(char *lump_file, int lump_size) void ProcessJunctionsLump(char *lump_file, int lump_size)
{ {
return; return;
@ -105,7 +105,7 @@ void ProcessJunctionsLump(char *lump_file, int lump_size)
/* end block 2 */ /* end block 2 */
// End Line: 505 // End Line: 505
// [D] // [D] [T]
void ProcessRoadsLump(char *lump_file, int lump_size) void ProcessRoadsLump(char *lump_file, int lump_size)
{ {
return; return;
@ -122,7 +122,7 @@ void ProcessRoadsLump(char *lump_file, int lump_size)
/* end block 1 */ /* end block 1 */
// End Line: 1676 // End Line: 1676
// [D] // [D] [T]
void ProcessRoadBoundsLump(char *lump_file, int lump_size) void ProcessRoadBoundsLump(char *lump_file, int lump_size)
{ {
return; return;
@ -139,7 +139,7 @@ void ProcessRoadBoundsLump(char *lump_file, int lump_size)
/* end block 1 */ /* end block 1 */
// End Line: 1678 // End Line: 1678
// [D] // [D] [T]
void ProcessJuncBoundsLump(char *lump_file, int lump_size) void ProcessJuncBoundsLump(char *lump_file, int lump_size)
{ {
return; return;
@ -262,31 +262,25 @@ MODEL * FindModelPtrWithName(char *name)
/* end block 3 */ /* end block 3 */
// End Line: 1558 // End Line: 1558
// [D] // [D] [T]
int FindModelIdxWithName(char *name) int FindModelIdxWithName(char *name)
{ {
char cVar1; char *str;
int iVar2; int i;
int iVar3;
char *__s1;
int iVar4;
iVar4 = 0; i = 0;
__s1 = modelname_buffer; str = modelname_buffer;
if (0 < num_models_in_pack) {
do { while (i < num_models_in_pack)
iVar2 = strcmp(__s1, name); {
iVar3 = iVar4 + 1; if (!strcmp(str, name))
if (iVar2 == 0) { return i;
return iVar4;
} while (*str++) {} // go to next string
do {
cVar1 = *__s1; i++;
__s1 = __s1 + 1;
} while (cVar1 != '\0');
iVar4 = iVar3;
} while (iVar3 < num_models_in_pack);
} }
return -1; return -1;
} }
@ -332,7 +326,7 @@ int sizeof_cell_object_computed_values;
CELL_DATA* cells; CELL_DATA* cells;
int num_straddlers; // objects between regions int num_straddlers; // objects between regions
// [D] // [D] [T]
void InitCellData(void) void InitCellData(void)
{ {
int loop; int loop;
@ -351,7 +345,7 @@ void InitCellData(void)
MALLOC_END(); MALLOC_END();
sizeof_cell_object_computed_values = (num_straddlers + cell_objects_add[4] + 7) / 8; sizeof_cell_object_computed_values = (num_straddlers + cell_objects_add[4] + 7) / sizeof(PACKED_CELL_OBJECT);
} }
@ -387,32 +381,38 @@ void InitCellData(void)
/* end block 4 */ /* end block 4 */
// End Line: 1774 // End Line: 1774
// [D] // [D] [T]
int newPositionVisible(VECTOR *pos, char *pvs, int ccx, int ccz) int newPositionVisible(VECTOR *pos, char *pvs, int ccx, int ccz)
{ {
int iVar1; int dx; // $a2
int iVar2; int dz; // $a0
int cellx; // $v1
int cellz; // $v0
iVar2 = pos->vx + units_across_halved; int ab;
iVar1 = pos->vz + units_down_halved;
ccx = (iVar2 >> 0xb) - ccx; dx = pos->vx + units_across_halved;
ccz = (iVar1 >> 0xb) - ccz; dz = pos->vz + units_down_halved;
iVar2 = ccx;
if (ccx < 0) cellx = (dx >> 0xb) - ccx;
iVar2 = -ccx; cellz = (dz >> 0xb) - ccz;
if (iVar2 <= view_dist) if (cellx < 0)
ab = -cellx;
else
ab = cellx;
if (ab <= view_dist)
{ {
iVar2 = ccz; if (cellz < 0)
ab = -cellz;
if (ccz < 0) else
iVar2 = -ccz; ab = cellz;
if (iVar2 <= view_dist) if (ab <= view_dist)
return pvs[ccx + 10 + (ccz + 10) * pvs_square] != 0; return pvs[cellx + 10 + (cellz + 10) * pvs_square] != 0;
} }
return 0; return 0;
} }
@ -449,32 +449,36 @@ int newPositionVisible(VECTOR *pos, char *pvs, int ccx, int ccz)
/* end block 4 */ /* end block 4 */
// End Line: 1771 // End Line: 1771
// [D] // [D] [T]
int PositionVisible(VECTOR *pos) int PositionVisible(VECTOR *pos)
{ {
int iVar1; int dx; // $a1
int iVar2; int dz; // $a0
int iVar3; int cellx; // $v1
int cellz; // $v0
iVar2 = pos->vx + units_across_halved; int ab;
iVar1 = pos->vz + units_down_halved;
iVar3 = (iVar2 >> 0xb) - current_cell_x; dx = pos->vx + units_across_halved;
iVar1 = (iVar1 >> 0xb) - current_cell_z; dz = pos->vz + units_down_halved;
iVar2 = iVar3; cellx = (dx >> 0xb) - current_cell_x;
cellz = (dz >> 0xb) - current_cell_z;
if (iVar3 < 0) if (cellx < 0)
iVar2 = -iVar3; ab = -cellx;
else
ab = cellx;
if (iVar2 <= view_dist) if (ab <= view_dist)
{ {
iVar2 = iVar1; if (cellz < 0)
if (iVar1 < 0) ab = -cellz;
iVar2 = -iVar1; else
ab = cellz;
if (iVar2 <= view_dist) if (ab <= view_dist)
return CurrentPVS[iVar3 + (iVar1 + 10) * pvs_square + 10] != 0; return CurrentPVS[cellx + 10 + (cellz + 10) * pvs_square] != 0;
} }
return 0; return 0;
@ -558,198 +562,170 @@ int region_z = 0;
int current_barrel_region_xcell = 0; int current_barrel_region_xcell = 0;
int current_barrel_region_zcell = 0; int current_barrel_region_zcell = 0;
// [D] // [D] [T]
int CheckUnpackNewRegions(void) int CheckUnpackNewRegions(void)
{ {
char bVar1; ushort sort;
ushort uVar2; ushort *destsort;
bool bVar3; ushort *srcsort;
int iVar4;
uint uVar5; int x, z;
int iVar6; int i, j;
int iVar7; int sortcount;
int iVar8; int leftright_unpack;
int iVar9; int topbottom_unpack;
ushort *puVar10;
ushort *puVar11;
int target_region; int target_region;
int iVar12; int region_to_unpack;
int num_regions_to_unpack;
int force_load_boundary;
AREA_LOAD_INFO regions_to_unpack[3]; AREA_LOAD_INFO regions_to_unpack[3];
SVECTOR sortregions[4]; SVECTOR sortregions[4];
ushort sortorder[4]; ushort sortorder[4];
iVar8 = 0; leftright_unpack = 0;
iVar9 = 0; topbottom_unpack = 0;
iVar12 = 0; num_regions_to_unpack = 0;
if (saved_leadcar_pos != 0) if (saved_leadcar_pos != 0)
{
return 0; return 0;
}
iVar7 = 0xd; force_load_boundary = 13;
if (lead_car == 0) if (lead_car == 0)
{ force_load_boundary = 18;
iVar7 = 0x12;
}
if (current_barrel_region_xcell < iVar7) if (current_barrel_region_xcell < force_load_boundary)
{ {
iVar4 = -1;
if (region_x != 0) if (region_x != 0)
{ {
iVar8 = 1; leftright_unpack = 1;
LAB_0005c8f8: num_regions_to_unpack = 1;
iVar12 = 1; regions_to_unpack[0].xoffset = -1;
regions_to_unpack[0].xoffset = iVar4;
regions_to_unpack[0].zoffset = 0; regions_to_unpack[0].zoffset = 0;
} }
} }
else if (0x20 - iVar7 < current_barrel_region_xcell) else if (0x20 - force_load_boundary < current_barrel_region_xcell)
{ {
iVar6 = cells_across; if (region_x < cells_across >> 5)
if (cells_across < 0)
{ {
iVar6 = cells_across + 0x1f; leftright_unpack = 2;
} num_regions_to_unpack = 1;
regions_to_unpack[0].xoffset = 1;
iVar4 = 1; regions_to_unpack[0].zoffset = 0;
if (region_x < iVar6 >> 5)
{
iVar8 = 2;
goto LAB_0005c8f8; // I really don't like this GOTO
} }
} }
if (current_barrel_region_zcell < iVar7) if (current_barrel_region_zcell < force_load_boundary)
{ {
if (region_z != 0) if (region_z != 0)
{ {
iVar9 = 1; topbottom_unpack = 1;
regions_to_unpack[iVar12].xoffset = 0; regions_to_unpack[num_regions_to_unpack].xoffset = 0;
iVar7 = -1; regions_to_unpack[num_regions_to_unpack].zoffset = -1;
LAB_0005c978: num_regions_to_unpack++;
regions_to_unpack[iVar12].zoffset = iVar7;
iVar12 = iVar12 + 1;
} }
} }
else if ((32 - iVar7 < current_barrel_region_zcell) && (region_z != 0)) else if (32 - force_load_boundary < current_barrel_region_zcell && region_z != 0)
{ {
iVar9 = 2; topbottom_unpack = 2;
regions_to_unpack[iVar12].xoffset = 0; regions_to_unpack[num_regions_to_unpack].xoffset = 0;
iVar7 = 1; regions_to_unpack[num_regions_to_unpack].zoffset = 1;
goto LAB_0005c978; num_regions_to_unpack++;
} }
if (iVar12 == 2) if (num_regions_to_unpack == 2)
{ {
if (iVar9 == 1) if (topbottom_unpack == 1)
{ {
iVar12 = 3; num_regions_to_unpack = 3;
if (iVar8 == 1)
if (leftright_unpack == 1)
{ {
regions_to_unpack[2].xoffset = -1; regions_to_unpack[2].xoffset = -1;
regions_to_unpack[2].zoffset = -1; regions_to_unpack[2].zoffset = -1;
goto LAB_0005c9dc;
} }
else
regions_to_unpack[2].xoffset = 1; {
regions_to_unpack[2].zoffset = -1; regions_to_unpack[2].xoffset = 1;
regions_to_unpack[2].zoffset = -1;
}
} }
else else
{ {
if (iVar8 == 1) if (leftright_unpack == 1)
regions_to_unpack[2].xoffset = -1; regions_to_unpack[2].xoffset = -1;
else else
regions_to_unpack[2].xoffset = 1; regions_to_unpack[2].xoffset = 1;
regions_to_unpack[2].zoffset = 1; regions_to_unpack[2].zoffset = 1;
} }
iVar12 = 3; num_regions_to_unpack = 3;
} }
LAB_0005c9dc: i = 0;
iVar9 = 0; sortcount = 0;
iVar8 = 0;
if (iVar12 != 0) // get next region a space
while (i < num_regions_to_unpack)
{ {
iVar7 = 0; x = regions_to_unpack[i].xoffset;
do { z = regions_to_unpack[i].zoffset;
iVar4 = regions_to_unpack[iVar9].xoffset;
iVar6 = regions_to_unpack[iVar9].zoffset;
iVar7 = cells_across; target_region = (region_x + x & 1U) + (region_z + z & 1U) * 2;
region_to_unpack = current_region + x + z * (cells_across / 32);
target_region = (region_x + iVar4 & 1U) + (region_z + iVar6 & 1U) * 2; if (region_to_unpack != regions_unpacked[target_region] && loading_region[target_region] == -1)
iVar7 = current_region + iVar4 + iVar6 * (iVar7 / 32); {
ClearRegion(target_region);
if ((iVar7 != regions_unpacked[target_region]) && (loading_region[target_region] == -1)) if (spoolinfo_offsets[region_to_unpack] == 0xffff)
{ {
ClearRegion(target_region); regions_unpacked[target_region] = region_to_unpack;
if (spoolinfo_offsets[iVar7] == 0xffff)
{
regions_unpacked[target_region] = iVar7;
}
else
{
uVar2 = spoolinfo_offsets[iVar7];
Spool *spoolptr = (Spool*)(RegionSpoolInfo + spoolinfo_offsets[iVar7]);
if (old_region == -1 && spoolptr->super_region != 0xFF)
initarea = spoolptr->super_region;
sortregions[iVar8].vx = iVar7;
sortregions[iVar8].vy = target_region;
sortregions[iVar8].vz = spoolptr->offset;// *(short *)(RegionSpoolInfo + uVar2);
sortorder[iVar8] = iVar8;
iVar8++;
}
} }
iVar9++; else
iVar7 = iVar9 * 8; {
} while (iVar9 < iVar12); Spool *spoolptr = (Spool*)(RegionSpoolInfo + spoolinfo_offsets[region_to_unpack]);
if (old_region == -1 && spoolptr->super_region != 0xFF)
initarea = spoolptr->super_region;
sortregions[sortcount].vx = region_to_unpack;
sortregions[sortcount].vy = target_region;
sortregions[sortcount].vz = spoolptr->offset;
sortorder[sortcount] = sortcount;
sortcount++;
}
}
i++;
} }
if (0 < iVar8) i = 0;
while (i < sortcount)
{ {
iVar12 = 0; if (sortcount > (i + 1))
iVar9 = 1; {
srcsort = sortorder + i;
destsort = sortorder + (i + 1);
do { j = sortcount - (i + 1);
if (iVar9 < iVar8)
{
puVar11 = sortorder + iVar12;
puVar10 = sortorder + iVar9;
iVar7 = iVar8 - iVar9;
do { do {
uVar2 = *puVar11; sort = *srcsort;
if (sortregions[*destsort].vz < sortregions[*srcsort].vz)
{
*srcsort = *destsort;
*destsort = sort;
}
if (sortregions[*puVar10].vz < sortregions[uVar2].vz) j--;
{ destsort++;
*puVar11 = *puVar10; } while (j > 0);
*puVar10 = uVar2; }
}
iVar7--; UnpackRegion(sortregions[sortorder[i]].vx, sortregions[sortorder[i]].vy);
puVar10++;
} while (iVar7 != 0);
}
uVar5 = sortorder[iVar12]; i++;
UnpackRegion(sortregions[uVar5].vx, sortregions[uVar5].vy);
bVar3 = iVar9 < iVar8;
iVar12 = iVar9;
iVar9 = iVar9 + 1;
} while (bVar3);
} }
return 1; return 1;
@ -809,7 +785,7 @@ LAB_0005c9dc:
extern OUT_CELL_FILE_HEADER cell_header; extern OUT_CELL_FILE_HEADER cell_header;
// [D] // [D] [T]
void ControlMap(void) void ControlMap(void)
{ {
#ifdef PSX #ifdef PSX
@ -979,76 +955,70 @@ void ControlMap(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void InitMap(void) void InitMap(void)
{ {
int iVar1;
unsigned char *pbVar2;
int region_to_unpack; int region_to_unpack;
int iVar3; int barrel_region;
int *piVar4; int i;
initarea = -1; initarea = -1;
LoadedArea = -1; LoadedArea = -1;
current_region = -1; current_region = -1;
if (slotsused < 19) i = slotsused;
{
pbVar2 = &tpageslots[slotsused];
iVar3 = slotsused;
do {
if (*pbVar2 != 0xff)
tpageloaded[*pbVar2] = 0;
*pbVar2++ = 0xff; while (i < 19)
iVar3++; {
} while (iVar3 < 19); int tpage = tpageslots[i];
if (tpage != 0xff)
tpageloaded[tpage] = 0;
tpageslots[i] = 0xff;
i++;
} }
// load regions synchronously // load regions synchronously
if (doSpooling == 0) if (doSpooling == 0)
{ {
old_region = -1; old_region = -1;
if (multiplayerregions[1] == -1) if (multiplayerregions[1] == -1)
{ {
multiplayerregions[1] = multiplayerregions[0] + 1; multiplayerregions[1] = multiplayerregions[0] + 1;
multiplayerregions[2] = multiplayerregions[0] - (cells_across >> 5); multiplayerregions[2] = multiplayerregions[0] - (cells_across >> 5);
multiplayerregions[3] = multiplayerregions[2] + 1; multiplayerregions[3] = multiplayerregions[2] + 1;
} }
piVar4 = multiplayerregions; i = 0;
iVar3 = 3;
do { do {
region_to_unpack = *piVar4; region_to_unpack = multiplayerregions[i];
iVar1 = cells_across >> 5;
if (spoolinfo_offsets[region_to_unpack] != 0xffff) if (spoolinfo_offsets[region_to_unpack] != 0xffff)
{ {
Spool *spoolptr = (Spool*)(RegionSpoolInfo + spoolinfo_offsets[region_to_unpack]); Spool* spoolptr = (Spool*)(RegionSpoolInfo + spoolinfo_offsets[region_to_unpack]);
if (spoolptr->super_region != 0xff) if (spoolptr->super_region != 0xff)
initarea = spoolptr->super_region; initarea = spoolptr->super_region;
UnpackRegion(region_to_unpack, (region_to_unpack % iVar1 & 1U) + (region_to_unpack / iVar1 & 1U) * 2); barrel_region = (region_to_unpack % (cells_across >> 5) & 1U) + (region_to_unpack / (cells_across >> 5) & 1U) * 2;
UnpackRegion(region_to_unpack, barrel_region);
} }
iVar3--; i++;
piVar4++; } while (i < 4);
} while (-1 < iVar3);
LoadInAreaTSets(initarea); LoadInAreaTSets(initarea);
LoadInAreaModels(initarea); LoadInAreaModels(initarea);
current_cell_x = camera_position.vx + units_across_halved; current_cell_x = camera_position.vx + units_across_halved >> 0xb;
current_cell_x = current_cell_x >> 0xb; current_cell_z = camera_position.vz + units_down_halved >> 0xb;
current_cell_z = camera_position.vz + units_down_halved;
current_cell_z = current_cell_z >> 0xb;
StartSpooling(); StartSpooling();
} }
else else
{ {
regions_unpacked[0] = -1; regions_unpacked[0] = -1;
regions_unpacked[1] = -1; regions_unpacked[1] = -1;
@ -1099,7 +1069,7 @@ void InitMap(void)
/* end block 3 */ /* end block 3 */
// End Line: 2686 // End Line: 2686
// [D] [A] // [D] [T] [A]
void GetVisSetAtPosition(VECTOR *pos, char *tgt, int *ccx, int *ccz) void GetVisSetAtPosition(VECTOR *pos, char *tgt, int *ccx, int *ccz)
{ {
int cz; int cz;
@ -1427,7 +1397,7 @@ void PVSDecode(char *output, char *celldata, ushort sz, int havanaCorruptCellBod
/* end block 5 */ /* end block 5 */
// End Line: 2055 // End Line: 2055
// [D] // [D] [T]
void GetPVSRegionCell2(int source_region, int region, int cell, char *output) void GetPVSRegionCell2(int source_region, int region, int cell, char *output)
{ {
int k; int k;

View File

@ -323,12 +323,10 @@ void startReadLevSectorsPC(int sector)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void test_changemode(void) void test_changemode(void)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
char bVar1;
SPOOLQ *current = &spooldata[spoolpos_reading]; SPOOLQ *current = &spooldata[spoolpos_reading];
if (spoolpos_reading == spoolcounter) if (spoolpos_reading == spoolcounter)
@ -346,10 +344,9 @@ void test_changemode(void)
else if (current_sector == current->sector) else if (current_sector == current->sector)
{ {
target_address = current->addr; target_address = current->addr;
bVar1 = current->type;
switch_spooltype = 1; switch_spooltype = 1;
if (bVar1 == 0) if (current->type == 0)
{ {
sectors_to_read = spool_regioninfo[spool_regionpos + 1].nsectors; sectors_to_read = spool_regioninfo[spool_regionpos + 1].nsectors;
sectors_this_chunk = (current->nsectors); sectors_this_chunk = (current->nsectors);
@ -359,21 +356,21 @@ void test_changemode(void)
levelSpoolerPCReadyCallback(ready_cb_regions); levelSpoolerPCReadyCallback(ready_cb_regions);
#endif // PSX #endif // PSX
} }
else if (bVar1 == 1) else if (current->type == 1)
{ {
sectors_to_read = 17; sectors_to_read = 17;
target_address += 0x4000; target_address += 0x4000;
nTPchunks_reading = 0; nTPchunks_reading = 0;
nTPchunks_writing = 0; nTPchunks_writing = 0;
ntpages = tsetcounter; ntpages = tsetcounter;
sectors_this_chunk = (uint)bVar1; sectors_this_chunk = 1;
#ifdef PSX #ifdef PSX
CdReadyCallback(ready_cb_textures); CdReadyCallback(ready_cb_textures);
#else #else
levelSpoolerPCReadyCallback(ready_cb_textures); levelSpoolerPCReadyCallback(ready_cb_textures);
#endif // PSX #endif // PSX
} }
else if (bVar1 == 2) else if (current->type == 2)
{ {
sectors_to_read = (current->nsectors); sectors_to_read = (current->nsectors);
send_bank = (current->data); send_bank = (current->data);
@ -381,7 +378,7 @@ void test_changemode(void)
nTPchunks_reading = 0; nTPchunks_reading = 0;
nTPchunks_writing = 0; nTPchunks_writing = 0;
target_address = target_address + (loadbank_read & 1U) * 0x1000; target_address = target_address + (loadbank_read & 1U) * 0x1000;
sectors_this_chunk = (uint)bVar1; sectors_this_chunk = 2;
#ifdef PSX #ifdef PSX
CdReadyCallback(ready_cb_soundbank); CdReadyCallback(ready_cb_soundbank);
@ -389,7 +386,7 @@ void test_changemode(void)
levelSpoolerPCReadyCallback(ready_cb_soundbank); levelSpoolerPCReadyCallback(ready_cb_soundbank);
#endif // PSX #endif // PSX
} }
else if (bVar1 == 3) else if (current->type == 3)
{ {
sectors_to_read = (current->nsectors); sectors_to_read = (current->nsectors);
#ifdef PSX #ifdef PSX
@ -428,7 +425,7 @@ void test_changemode(void)
/* end block 2 */ /* end block 2 */
// End Line: 5398 // End Line: 5398
// [D] // [D] [T]
void changemode(SPOOLQ *current) void changemode(SPOOLQ *current)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -519,122 +516,139 @@ void changemode(SPOOLQ *current)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
int check_regions_present(void) int check_regions_present(void)
{ {
AREA_LOAD_INFO *pAVar1; int barrel_region;
int iVar2; int x, z;
int iVar3; int region_to_unpack;
int iVar4; int num_regions_to_unpack;
int iVar5; int leftright_unpack;
AREA_LOAD_INFO *pAVar6; int topbottom_unpack;
AREA_LOAD_INFO region_to_unpack[3]; int retval;
AREA_LOAD_INFO regions_to_unpack[3];
char textbuf[128]; char textbuf[128];
pAVar6 = region_to_unpack; leftright_unpack = 0;
iVar4 = 0; topbottom_unpack = 0;
iVar5 = 0; num_regions_to_unpack = 0;
iVar3 = 0;
if (current_barrel_region_xcell < 9) { if (current_barrel_region_xcell < 9)
region_to_unpack[0].xoffset = -1; {
if (region_x != 0) { regions_to_unpack[0].xoffset = -1;
iVar4 = 1; if (region_x != 0)
LAB_0007b44c: {
iVar3 = 1; leftright_unpack = 1;
region_to_unpack[0].zoffset = 0; num_regions_to_unpack = 1;
regions_to_unpack[0].zoffset = 0;
} }
} }
else { else if (current_barrel_region_xcell > 23)
if (0x17 < current_barrel_region_xcell) { {
iVar2 = cells_across; regions_to_unpack[0].xoffset = 1;
if (cells_across < 0) {
iVar2 = cells_across + 0x1f; if (region_x < (cells_across >> 5))
} {
region_to_unpack[0].xoffset = 1; leftright_unpack = 2;
if (region_x < iVar2 >> 5) { num_regions_to_unpack = 1;
iVar4 = 2; regions_to_unpack[0].zoffset = 0;
goto LAB_0007b44c;
}
} }
} }
if (current_barrel_region_zcell < 9) {
if (region_z == 0) goto LAB_0007b4e0; if (current_barrel_region_zcell < 9 && region_z != 0)
iVar5 = 1; {
region_to_unpack[iVar3].xoffset = 0; topbottom_unpack = 1;
iVar2 = -1;
regions_to_unpack[num_regions_to_unpack].xoffset = 0;
regions_to_unpack[num_regions_to_unpack].zoffset = -1;
num_regions_to_unpack++;
} }
else { else if(current_barrel_region_zcell > 23 && region_z != 0)
if ((current_barrel_region_zcell < 0x18) || (region_z == 0)) goto LAB_0007b4e0; {
iVar5 = 2; topbottom_unpack = 2;
region_to_unpack[iVar3].xoffset = 0;
iVar2 = 1; regions_to_unpack[num_regions_to_unpack].xoffset = 0;
regions_to_unpack[num_regions_to_unpack].zoffset = 1;
num_regions_to_unpack++;
} }
pAVar1 = region_to_unpack + iVar3;
iVar3 = iVar3 + 1; if (num_regions_to_unpack == 2)
pAVar1->zoffset = iVar2; {
LAB_0007b4e0: num_regions_to_unpack = 3;
if (iVar3 == 2) {
if (iVar5 == 1) { if (topbottom_unpack == 1)
iVar3 = 3; {
if (iVar4 == 1) { if (leftright_unpack == 1)
region_to_unpack[2].xoffset = -1; {
region_to_unpack[2].zoffset = -1; regions_to_unpack[2].xoffset = -1;
regions_to_unpack[2].zoffset = -1;
} }
else { else
region_to_unpack[2].xoffset = 1; {
region_to_unpack[2].zoffset = -1; regions_to_unpack[2].xoffset = 1;
regions_to_unpack[2].zoffset = -1;
} }
} }
else { else
iVar3 = 3; {
if (iVar4 == 1) { if (leftright_unpack == 1)
region_to_unpack[2].xoffset = -1; regions_to_unpack[2].xoffset = -1;
} else
else { regions_to_unpack[2].xoffset = 1;
region_to_unpack[2].xoffset = 1;
} regions_to_unpack[2].zoffset = 1;
region_to_unpack[2].zoffset = 1;
} }
} }
iVar4 = 0;
while (iVar3 != 0) { retval = 0;
iVar5 = cells_across; while (num_regions_to_unpack != 0)
if (cells_across < 0) { {
iVar5 = cells_across + 0x1f; x = regions_to_unpack[retval].xoffset;
z = regions_to_unpack[retval].zoffset;
region_to_unpack = current_region + x + z * (cells_across >> 5);
if (loading_region[(region_x + x & 1U) + (region_z + z & 1U) * 2] != -1 &&
spoolinfo_offsets[region_to_unpack] != 0xffff &&
loading_region[(region_x + x & 1U) + (region_z + z & 1U) * 2] == region_to_unpack)
{
retval++;
} }
iVar5 = current_region + *(int *)pAVar6 + ((int *)pAVar6)[1] * (iVar5 >> 5); num_regions_to_unpack--;
if ((((int)loading_region[(region_x + *(int *)pAVar6 & 1U) + (region_z + ((int *)pAVar6)[1] & 1U) * 2] !=
-1) && (spoolinfo_offsets[iVar5] != 0xffff)) &&
((int)loading_region
[(region_x + *(int *)pAVar6 & 1U) + (region_z + ((int *)pAVar6)[1] & 1U) * 2] ==
iVar5)) {
iVar4 = iVar4 + 1;
}
iVar3 = iVar3 + -1;
pAVar6 = (AREA_LOAD_INFO *)((int *)pAVar6 + 2);
} }
if (LoadingArea != 0) {
if (new_area_location == 1) { if (LoadingArea != 0)
if (0x1a < current_barrel_region_xcell) { {
iVar4 = iVar4 + 1; if (new_area_location == 1)
{
if (current_barrel_region_xcell > 26)
{
retval++;
} }
} }
else { else
if (new_area_location < 2) { {
if ((new_area_location == 0) && (0x1a < current_barrel_region_zcell)) { if (new_area_location < 2)
iVar4 = iVar4 + 1; {
if (new_area_location == 0 && current_barrel_region_zcell > 26)
{
retval++;
} }
} }
else { else
iVar3 = current_barrel_region_zcell; {
if (((new_area_location == 2) || barrel_region = current_barrel_region_zcell;
(iVar3 = current_barrel_region_xcell, new_area_location == 3)) && (iVar3 < 6)) { if ((new_area_location == 2 ||
iVar4 = iVar4 + 1; (barrel_region = current_barrel_region_xcell, new_area_location == 3)) &&
barrel_region < 6)
{
retval++;
} }
} }
} }
} }
return iVar4;
return retval;
} }
@ -662,7 +676,7 @@ LAB_0007b4e0:
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void stopgame(void) void stopgame(void)
{ {
StopPadVibration(0); StopPadVibration(0);
@ -702,7 +716,7 @@ void stopgame(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void startgame(void) void startgame(void)
{ {
PutDrawEnv(&current->draw); PutDrawEnv(&current->draw);
@ -742,7 +756,7 @@ void startgame(void)
extern POLY_FT4 cd_sprite; extern POLY_FT4 cd_sprite;
extern unsigned short cd_icon[288]; extern unsigned short cd_icon[288];
// [D] // [D] [T]
void DrawCDicon(void) void DrawCDicon(void)
{ {
ushort *palette; ushort *palette;
@ -802,7 +816,7 @@ void DrawCDicon(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void CheckValidSpoolData(void) void CheckValidSpoolData(void)
{ {
if (models_ready) if (models_ready)
@ -863,7 +877,7 @@ void CheckValidSpoolData(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void UpdateSpool(void) void UpdateSpool(void)
{ {
#ifdef SIMPLE_SPOOL #ifdef SIMPLE_SPOOL
@ -1075,7 +1089,7 @@ void UpdateSpool(void)
/* end block 3 */ /* end block 3 */
// End Line: 6448 // End Line: 6448
// [D] // [D] [T]
#ifdef _DEBUG #ifdef _DEBUG
void _RequestSpool(int type, int data, int offset, int loadsize, char *address, spooledFuncPtr func, const char* requestby, int line) void _RequestSpool(int type, int data, int offset, int loadsize, char *address, spooledFuncPtr func, const char* requestby, int line)
#define RequestSpool(type, data, offset, loadsize, loadaddr, func) _RequestSpool(type, data, offset, loadsize, loadaddr, func, __FUNCTION__, __LINE__) #define RequestSpool(type, data, offset, loadsize, loadaddr, func) _RequestSpool(type, data, offset, loadsize, loadaddr, func, __FUNCTION__, __LINE__)
@ -1144,7 +1158,7 @@ void RequestSpool(int type, int data, int offset, int loadsize, char *address, s
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void InitSpooling(void) void InitSpooling(void)
{ {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -1219,25 +1233,26 @@ void InitSpooling(void)
int tsetinfo[32]; int tsetinfo[32];
// [D] // [D] [T]
void SendTPage(void) void SendTPage(void)
{ {
unsigned char bVar1; unsigned char old;
ulong *clutptr; ulong *clutptr;
int iVar5; int slot;
int npalettes; int npalettes;
int iVar7; int tpage2send;
int i;
RECT16 cluts; RECT16 cluts;
iVar7 = tsetinfo[tsetpos * 2]; tpage2send = tsetinfo[tsetpos * 2];
iVar5 = tsetinfo[tsetpos * 2 + 1]; slot = tsetinfo[tsetpos * 2 + 1];
if (iVar7 == 0xFF || iVar5 == 0xFF) // [A] bug fix if (tpage2send == 0xFF || slot == 0xFF) // [A] bug fix
return; return;
if (nTPchunks == 0) if (nTPchunks == 0)
{ {
if (iVar5 != tpageloaded[iVar7]-1) if (slot != tpageloaded[tpage2send]-1)
{ {
npalettes = *(int *)(model_spool_buffer + 0xE000); npalettes = *(int *)(model_spool_buffer + 0xE000);
@ -1245,43 +1260,37 @@ void SendTPage(void)
tpage.h = 64; tpage.h = 64;
cluts.w = 64; cluts.w = 64;
tpage.x = slot_tpagepos[iVar5].vx; tpage.x = slot_tpagepos[slot].vx;
tpage.y = slot_tpagepos[iVar5].vy; tpage.y = slot_tpagepos[slot].vy;
cluts.y = slot_clutpos[iVar5].vy; cluts.y = slot_clutpos[slot].vy;
cluts.x = slot_clutpos[iVar5].vx; cluts.x = slot_clutpos[slot].vx;
cluts.h = npalettes / 4 + 1; cluts.h = npalettes / 4 + 1;
LoadImage(&cluts, (u_long *)(model_spool_buffer + 0xE000 + 4)); LoadImage(&cluts, (u_long *)(model_spool_buffer + 0xE000 + 4));
clutptr = (ulong *)(texture_cluts[iVar7]); clutptr = (ulong *)(texture_cluts[tpage2send]);
iVar5 = 0; i = 0;
if (0 < npalettes) while (i < npalettes)
{ {
do { clutptr[0] = getClut(cluts.x + 16, cluts.y) << 0x10 | getClut(cluts.x, cluts.y);
//int test1 = (uVar3 | iVar2 + 0x10 >> 4 & 0x3fU) << 0x10 | uVar3 | (int)((uint)cluts.x << 0x10) >> 0x14 & 0x3fU; clutptr[1] = getClut(cluts.x + 48, cluts.y) << 0x10 | getClut(cluts.x + 32, cluts.y);
//int test2 = (uVar3 | iVar2 + 0x30 >> 4 & 0x3fU) << 0x10 | uVar3 | iVar2 + 0x20 >> 4 & 0x3fU;
clutptr[0] = getClut(cluts.x + 16, cluts.y) << 0x10 | getClut(cluts.x, cluts.y); clutptr+=2;
clutptr[1] = getClut(cluts.x + 48, cluts.y) << 0x10 | getClut(cluts.x + 32, cluts.y);
clutptr+=2; cluts.y++;
cluts.y++;
iVar5 += 4;; i += 4;
} while (iVar5 < npalettes);
} }
texture_pages[iVar7] = getTPage(0, 0, tpage.x, tpage.y); texture_pages[tpage2send] = getTPage(0, 0, tpage.x, tpage.y);
// OLD VALUE: (short)(tpage.y & 0x100U) >> 4 | (ushort)(((uint)(ushort)tpage.x & 0x3ff) >> 6) | (ushort)(((uint)(ushort)tpage.y & 0x200) << 2);
// please check me if above is correct
} }
} }
else else
{ {
if (iVar5 != tpageloaded[iVar7] - 1) if (slot != tpageloaded[tpage2send] - 1)
{ {
LoadImage(&tpage, (u_long *)(model_spool_buffer + 0xA000 + (loadbank_write % 2) * TPAGE_WIDTH * 32)); LoadImage(&tpage, (u_long *)(model_spool_buffer + 0xA000 + (loadbank_write % 2) * TPAGE_WIDTH * 32));
tpage.y = tpage.y + tpage.h; tpage.y = tpage.y + tpage.h;
@ -1289,13 +1298,13 @@ void SendTPage(void)
if (nTPchunks == 4) if (nTPchunks == 4)
{ {
bVar1 = tpageslots[iVar5]; old = tpageslots[slot];
tpageslots[iVar5] = iVar7; tpageslots[slot] = tpage2send;
if(bVar1 != 0xFF) // [A] bug fix if(old != 0xFF) // [A] bug fix
tpageloaded[bVar1] = 0; tpageloaded[old] = 0;
tpageloaded[iVar7] = iVar5 + 1; tpageloaded[tpage2send] = slot + 1;
tsetpos++; tsetpos++;
@ -1331,7 +1340,7 @@ void SendTPage(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void SpoolSYNC(void) void SpoolSYNC(void)
{ {
do { do {
@ -1376,15 +1385,10 @@ void SpoolSYNC(void)
/* end block 4 */ /* end block 4 */
// End Line: 2661 // End Line: 2661
// [D] // [D] [T]
void LoadInAreaTSets(int area) void LoadInAreaTSets(int area)
{ {
bool bVar1;
uint uVar3;
int iVar4;
int offset; int offset;
int *piVar5;
int i; int i;
int slot; int slot;
@ -1404,7 +1408,6 @@ void LoadInAreaTSets(int area)
if (slotsused < 19) if (slotsused < 19)
{ {
piVar5 = availableslots;
slot = slotsused; slot = slotsused;
do { do {
@ -1412,28 +1415,22 @@ void LoadInAreaTSets(int area)
if (tpageslots[slot] == 0xff) // [A] if (tpageslots[slot] == 0xff) // [A]
{ {
*piVar5++ = slot; availableslots[navailable++] = slot;
navailable++;
} }
else else
{ {
if (ntpages_to_load != 0 && tpageslots[slot] != *tpages) // [A] i = 0;
while (tpageslots[slot] != tpages[i]) // [A]
{ {
uVar3 = 1; if (ntpages_to_load <= i)
do { break;
offset = uVar3;
if (ntpages_to_load <= offset) i++;
break; };
uVar3 = offset + 1; if (i == ntpages_to_load)
} while (tpageslots[slot] != tpages[offset]); // [A]
}
if (offset == ntpages_to_load)
{ {
*piVar5++ = slot; availableslots[navailable++] = slot;
navailable++;
} }
} }
@ -1446,23 +1443,16 @@ void LoadInAreaTSets(int area)
if (ntpages_to_load != 0) if (ntpages_to_load != 0)
{ {
uVar3 = *tpages; if (tpageloaded[*tpages] != 0) // weird goto lol
if (tpageloaded[uVar3] != 0) // weird goto lol
{ {
goto LAB_0007bc94; goto LAB_0007bc94;
} }
bVar1 = 0 < navailable; if (navailable-- > 0)
navailable--;
if (bVar1)
{ {
iVar4 = availableslots[navailable];
while (true) while (true)
{ {
tsetinfo[tsetcounter*2 + 1] = iVar4; tsetinfo[tsetcounter*2 + 1] = availableslots[navailable];
while (true) while (true)
{ {
@ -1478,21 +1468,17 @@ void LoadInAreaTSets(int area)
if (ntpages_to_load <= i) if (ntpages_to_load <= i)
return; return;
uVar3 = *tpages; if (tpageloaded[*tpages] == 0)
if (tpageloaded[uVar3] == 0)
break; break;
LAB_0007bc94: LAB_0007bc94:
tsetinfo[tsetcounter * 2 + 1] = tpageloaded[uVar3] - 1; tsetinfo[tsetcounter * 2 + 1] = tpageloaded[*tpages] - 1;
} }
if (navailable < 1) if (navailable < 1)
break; break;
navailable--; navailable--;
iVar4 = availableslots[navailable];
} }
} }
} }
@ -1638,7 +1624,7 @@ void SendSBK(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void init_spooled_models(void) void init_spooled_models(void)
{ {
int nmodels; int nmodels;
@ -1657,12 +1643,6 @@ void init_spooled_models(void)
SPOOL_INFO("loading %d model slots\n", nmodels); SPOOL_INFO("loading %d model slots\n", nmodels);
//for (i = 0; i < 1536; i++)
//{
// if (addr <= (char*)&modelpointers[i])
// modelpointers[i] = &dummyModel;
//}
unsigned short* new_model_numbers = newmodels + 1; unsigned short* new_model_numbers = newmodels + 1;
for (i = 0; i < nmodels; i++) for (i = 0; i < nmodels; i++)
@ -1731,7 +1711,7 @@ void init_spooled_models(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void SetupModels(void) void SetupModels(void)
{ {
if (old_region == -1) if (old_region == -1)
@ -1771,7 +1751,7 @@ void SetupModels(void)
/* end block 4 */ /* end block 4 */
// End Line: 7975 // End Line: 7975
// [D] // [D] [T]
void LoadInAreaModels(int area) void LoadInAreaModels(int area)
{ {
if (newmodels) if (newmodels)
@ -1830,7 +1810,7 @@ void LoadInAreaModels(int area)
/* end block 4 */ /* end block 4 */
// End Line: 3523 // End Line: 3523
// [D] // [D] [T]
void CheckLoadAreaData(int cellx, int cellz) void CheckLoadAreaData(int cellx, int cellz)
{ {
int nAreas; int nAreas;
@ -1958,7 +1938,7 @@ void CheckLoadAreaData(int cellx, int cellz)
/* end block 4 */ /* end block 4 */
// End Line: 7605 // End Line: 7605
// [D] // [D] [T]
void ClearRegion(int target_region) void ClearRegion(int target_region)
{ {
long *pvsptr; long *pvsptr;
@ -2005,7 +1985,7 @@ void ClearRegion(int target_region)
extern bool gDemoLevel; extern bool gDemoLevel;
extern bool gDriver1Level; extern bool gDriver1Level;
// [D] // [D] [T]
int LoadRegionData(int region, int target_region) int LoadRegionData(int region, int target_region)
{ {
char *cell_buffer; char *cell_buffer;
@ -2099,7 +2079,7 @@ int LoadRegionData(int region, int target_region)
int RoadMapRegions[4]; int RoadMapRegions[4];
// [D] // [D] [T]
void UnpackRegion(int region_to_unpack, int target_barrel_region) void UnpackRegion(int region_to_unpack, int target_barrel_region)
{ {
if (loading_region[target_barrel_region] == -1) if (loading_region[target_barrel_region] == -1)
@ -2151,7 +2131,7 @@ inline int _getIntAdv(char** ptr)
#define getIntAdv(ptr) _getIntAdv(&ptr) #define getIntAdv(ptr) _getIntAdv(&ptr)
// [D] // [D] [T]
void ProcessSpoolInfoLump(char *lump_ptr, int lump_size) void ProcessSpoolInfoLump(char *lump_ptr, int lump_size)
{ {
int i; int i;
@ -2261,7 +2241,7 @@ void ProcessSpoolInfoLump(char *lump_ptr, int lump_size)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void WaitCloseLid(void) void WaitCloseLid(void)
{ {
#ifdef PSX #ifdef PSX
@ -2318,7 +2298,7 @@ void WaitCloseLid(void)
/* end block 5 */ /* end block 5 */
// End Line: 8769 // End Line: 8769
// [D] // [D] [T]
void FoundError(char *name, unsigned char intr, unsigned char *result) void FoundError(char *name, unsigned char intr, unsigned char *result)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -2383,7 +2363,7 @@ void FoundError(char *name, unsigned char intr, unsigned char *result)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void GotRegion(void) void GotRegion(void)
{ {
uint target_barrel_reg; uint target_barrel_reg;
@ -2444,7 +2424,7 @@ void GotRegion(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void data_cb_textures(void) void data_cb_textures(void)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -2533,7 +2513,7 @@ void data_cb_textures(void)
/* end block 3 */ /* end block 3 */
// End Line: 6774 // End Line: 6774
// [D] // [D] [T]
void ready_cb_textures(unsigned char intr, unsigned char *result) void ready_cb_textures(unsigned char intr, unsigned char *result)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -2622,6 +2602,7 @@ void ready_cb_textures(unsigned char intr, unsigned char *result)
/* end block 3 */ /* end block 3 */
// End Line: 4181 // End Line: 4181
// [D] [T]
void ready_cb_regions(unsigned char intr, unsigned char *result) void ready_cb_regions(unsigned char intr, unsigned char *result)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -2694,7 +2675,7 @@ void ready_cb_regions(unsigned char intr, unsigned char *result)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void data_cb_regions(void) void data_cb_regions(void)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -2918,7 +2899,7 @@ void ready_cb_soundbank(unsigned char intr, unsigned char *result)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void data_cb_misc(void) void data_cb_misc(void)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -2980,7 +2961,7 @@ void data_cb_misc(void)
/* end block 2 */ /* end block 2 */
// End Line: 6748 // End Line: 6748
// [D] // [D] [T]
void ready_cb_misc(unsigned char intr, unsigned char *result) void ready_cb_misc(unsigned char intr, unsigned char *result)
{ {
#ifndef SIMPLE_SPOOL #ifndef SIMPLE_SPOOL
@ -3040,10 +3021,10 @@ void ready_cb_misc(unsigned char intr, unsigned char *result)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void StartSpooling(void) void StartSpooling(void)
{ {
if ((spoolcounter != 0) && !spoolactive) if (spoolcounter != 0 && !spoolactive)
{ {
if (!XAPrepared()) if (!XAPrepared())
{ {
@ -3112,69 +3093,68 @@ void StartSpooling(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] [A] - altered declaration // [D] [T] [A] - altered declaration
void unpack_cellpointers(int region_to_unpack, int target_barrel_region, char* cell_addr) void unpack_cellpointers(int region_to_unpack, int target_barrel_region, char* cell_addr)
{ {
ushort *puVar1; ushort cell;
ushort *puVar2; ushort* short_ptr;
ushort uVar3; ushort* source_packed_data;
int loop; int loop;
uint uVar6; uint bitpos;
uint uVar7; uint pcode;
int packtype; int packtype;
unpack_cellptr_flag = 0; unpack_cellptr_flag = 0;
packtype = *(int *)(cell_addr + 4); packtype = *(int *)(cell_addr + 4);
puVar1 = (ushort *)(cell_addr + 8); source_packed_data = (ushort *)(cell_addr + 8);
if (packtype == 0) if (packtype == 0)
{ {
puVar1 = cell_ptrs + target_barrel_region * 1024; short_ptr = cell_ptrs + target_barrel_region * 1024;
for (loop = 0; loop < 1024; loop++) for (loop = 0; loop < 1024; loop++)
*puVar1++ = 0xffff; *short_ptr++ = 0xffff;
} }
else if (packtype == 1) else if (packtype == 1)
{ {
puVar2 = cell_ptrs + target_barrel_region * 1024; short_ptr = cell_ptrs + target_barrel_region * 1024;
for (loop = 0; loop < 1024; loop++) for (loop = 0; loop < 1024; loop++)
{ {
uVar3 = *puVar1++; cell = *source_packed_data++;
if (uVar3 != 0xffff) if (cell != 0xffff)
uVar3 += cell_slots_add[target_barrel_region]; cell += cell_slots_add[target_barrel_region];
*puVar2++ = uVar3; *short_ptr++ = cell;
} }
} }
else if (packtype == 2) else if (packtype == 2)
{ {
uVar6 = 0x8000; bitpos = 0x8000;
uVar7 = (uint)*puVar1; pcode = (uint)*source_packed_data;
source_packed_data++;
puVar2 = (ushort *)(cell_addr + 10); short_ptr = cell_ptrs + target_barrel_region * 1024;
puVar1 = cell_ptrs + target_barrel_region * 1024;
for (loop = 0; loop < 1024; loop++) for (loop = 0; loop < 1024; loop++)
{ {
if (uVar7 & uVar6) if (pcode & bitpos)
{ {
uVar3 = *puVar2++; cell = *source_packed_data++;
uVar3 += cell_slots_add[target_barrel_region]; cell += cell_slots_add[target_barrel_region];
} }
else else
uVar3 = 0xffff; cell = 0xffff;
uVar6 >>= 1; bitpos >>= 1;
*puVar1++ = uVar3; *short_ptr++ = cell;
if (uVar6 == 0) if (bitpos == 0)
{ {
uVar6 = 0x8000; bitpos = 0x8000;
uVar7 = *puVar2++; pcode = *source_packed_data++;
} }
} }
} }
@ -3220,7 +3200,7 @@ void unpack_cellpointers(int region_to_unpack, int target_barrel_region, char* c
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] [A] altered unpack_cellpointers // [D] [T] [A] altered unpack_cellpointers
void Unpack_CellPtrs(void) void Unpack_CellPtrs(void)
{ {
SPL_REGIONINFO* spool = &spool_regioninfo[spool_regionpos]; SPL_REGIONINFO* spool = &spool_regioninfo[spool_regionpos];
@ -3285,7 +3265,7 @@ void Unpack_CellPtrs(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] [A] // [D] [T] [A]
void SpecClutsSpooled(void) void SpecClutsSpooled(void)
{ {
char *loadaddr; char *loadaddr;
@ -3386,7 +3366,7 @@ int specialState = 0;
char specModelValid = 1; char specModelValid = 1;
int specSpoolComplete; int specSpoolComplete;
// [D] // [D] [T]
void CleanModelSpooled(void) void CleanModelSpooled(void)
{ {
int *loadaddr; int *loadaddr;
@ -3473,7 +3453,7 @@ void CleanModelSpooled(void)
int damOffset; int damOffset;
// [D] // [D] [T]
void DamagedModelSpooled(void) void DamagedModelSpooled(void)
{ {
int *loadaddr; int *loadaddr;
@ -3557,7 +3537,7 @@ void DamagedModelSpooled(void)
int lowOffset; int lowOffset;
// [D] // [D] [T]
void LowModelSpooled(void) void LowModelSpooled(void)
{ {
int *loadaddr; int *loadaddr;
@ -3643,7 +3623,7 @@ void LowModelSpooled(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] [A] // [D] [T] [A]
void CleanSpooled(void) void CleanSpooled(void)
{ {
MODEL *model; MODEL *model;
@ -3737,7 +3717,7 @@ void CleanSpooled(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void LowSpooled(void) void LowSpooled(void)
{ {
MODEL *model; MODEL *model;
@ -3822,7 +3802,7 @@ void LowSpooled(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void Tada(void) void Tada(void)
{ {
int spec_tpage; int spec_tpage;
@ -3918,7 +3898,7 @@ void Tada(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void SpecialStartNextBlock(void) void SpecialStartNextBlock(void)
{ {
char *loadaddr; char *loadaddr;
@ -4060,7 +4040,7 @@ void SpecialStartNextBlock(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void CheckSpecialSpool(void) void CheckSpecialSpool(void)
{ {
int ret; int ret;
@ -4137,7 +4117,7 @@ void CheckSpecialSpool(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void QuickSpoolSpecial(void) void QuickSpoolSpecial(void)
{ {
quickSpool = 1; quickSpool = 1;
@ -4176,7 +4156,7 @@ void QuickSpoolSpecial(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void PrepareSecretCar(void) void PrepareSecretCar(void)
{ {
allowSpecSpooling = 0; allowSpecSpooling = 0;
@ -4218,7 +4198,7 @@ void PrepareSecretCar(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */ /* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] // [D] [T]
void InitSpecSpool(void) void InitSpecSpool(void)
{ {
switch (gCurrentMissionNumber) switch (gCurrentMissionNumber)