2020-09-05 20:12:14 +02:00
|
|
|
#include "DRIVER2.H"
|
2020-05-01 10:51:44 +02:00
|
|
|
|
|
|
|
#include "LIBGTE.H"
|
|
|
|
#include "LIBGPU.H"
|
|
|
|
#include "INLINE_C.H"
|
2020-10-08 17:25:40 +02:00
|
|
|
#include "C/MISSION.H"
|
|
|
|
|
|
|
|
#include "C/CONVERT.H"
|
|
|
|
#include "C/CAMERA.H"
|
|
|
|
#include "C/DRAW.H"
|
|
|
|
#include "C/SYSTEM.H"
|
|
|
|
#include "C/PRES.H"
|
|
|
|
#include "C/SPOOL.H"
|
|
|
|
#include "C/CARS.H"
|
|
|
|
#include "C/PLAYERS.H"
|
|
|
|
#include "C/GLAUNCH.H"
|
2020-05-01 10:51:44 +02:00
|
|
|
|
2020-05-06 13:22:54 +02:00
|
|
|
int gDisplayDrawStats = 0;
|
2020-05-01 10:51:44 +02:00
|
|
|
|
|
|
|
struct LineDef_t
|
|
|
|
{
|
|
|
|
VECTOR posA, posB;
|
|
|
|
CVECTOR color;
|
|
|
|
};
|
|
|
|
|
|
|
|
LineDef_t gDebug_Lines[512];
|
|
|
|
int gDebug_numLines = 0;
|
|
|
|
|
|
|
|
void DrawDebugOverlays()
|
|
|
|
{
|
|
|
|
VECTOR _zerov = { 0 };
|
|
|
|
|
|
|
|
while(gDebug_numLines > 0)
|
|
|
|
{
|
|
|
|
LineDef_t& ld = gDebug_Lines[gDebug_numLines-1];
|
|
|
|
|
|
|
|
gte_SetTransVector(&_zerov);
|
|
|
|
gte_SetRotMatrix(&inv_camera_matrix);
|
|
|
|
|
|
|
|
SVECTOR a, b;
|
|
|
|
a.vx = ld.posA.vx - camera_position.vx;
|
|
|
|
a.vy = ld.posA.vy - camera_position.vy;
|
|
|
|
a.vz = ld.posA.vz - camera_position.vz;
|
|
|
|
|
|
|
|
b.vx = ld.posB.vx - camera_position.vx;
|
|
|
|
b.vy = ld.posB.vy - camera_position.vy;
|
|
|
|
b.vz = ld.posB.vz - camera_position.vz;
|
|
|
|
|
2020-05-23 20:17:30 +02:00
|
|
|
gte_ldv3(&a, &b, &b);
|
2020-05-01 10:51:44 +02:00
|
|
|
|
2020-05-23 20:17:30 +02:00
|
|
|
gte_rtpt();
|
|
|
|
gte_avsz4();
|
|
|
|
|
|
|
|
int z;
|
|
|
|
gte_stopz(&z);
|
2020-05-01 10:51:44 +02:00
|
|
|
|
2020-05-23 20:17:30 +02:00
|
|
|
if (z > 0)
|
2020-05-10 11:30:24 +02:00
|
|
|
{
|
|
|
|
LINE_F2* line = (LINE_F2*)current->primptr;
|
|
|
|
setLineF2(line);
|
|
|
|
setSemiTrans(line, 1);
|
2020-05-22 10:51:20 +02:00
|
|
|
|
|
|
|
gte_stsxy0(&line->x0)
|
|
|
|
gte_stsxy1(&line->x1);
|
|
|
|
|
2020-05-10 11:30:24 +02:00
|
|
|
line->r0 = ld.color.r;
|
|
|
|
line->g0 = ld.color.g;
|
|
|
|
line->b0 = ld.color.b;
|
|
|
|
|
|
|
|
addPrim(current->ot + 2, line);
|
|
|
|
|
|
|
|
current->primptr += sizeof(LINE_F2);
|
|
|
|
}
|
2020-05-01 10:51:44 +02:00
|
|
|
gDebug_numLines--;
|
|
|
|
}
|
|
|
|
gDebug_numLines = 0;
|
2020-05-06 13:22:54 +02:00
|
|
|
|
2020-05-10 11:30:24 +02:00
|
|
|
DR_TPAGE* tp = (DR_TPAGE*)current->primptr;
|
|
|
|
setDrawTPage(tp, 0, 0, 0);
|
|
|
|
addPrim(current->ot + 2, tp);
|
|
|
|
current->primptr += sizeof(DR_TPAGE);
|
|
|
|
|
2020-05-06 13:22:54 +02:00
|
|
|
char tempBuf[128];
|
|
|
|
|
|
|
|
int primTabLeft = current->primptr - current->primtab;
|
|
|
|
|
|
|
|
if (gDisplayDrawStats)
|
|
|
|
{
|
2020-10-17 11:27:44 +02:00
|
|
|
SetTextColour(255, 255, 0);
|
|
|
|
|
2020-08-26 20:01:55 +02:00
|
|
|
sprintf(tempBuf, "Primtab: %d of %d", primTabLeft, PRIMTAB_SIZE);
|
2020-08-26 15:50:03 +02:00
|
|
|
PrintString(tempBuf, 10, 20);
|
2020-05-06 13:22:54 +02:00
|
|
|
|
|
|
|
extern volatile int spoolactive;
|
|
|
|
sprintf(tempBuf, "Spooling: %d spec: %d, active: %d", doSpooling, allowSpecSpooling, spoolactive);
|
2020-08-26 15:50:03 +02:00
|
|
|
PrintString(tempBuf, 10, 30);
|
2020-05-27 13:04:24 +02:00
|
|
|
|
|
|
|
extern int numActiveCops;
|
|
|
|
extern int numCopCars;
|
|
|
|
extern int numCivCars;
|
|
|
|
extern int numParkedCars;
|
|
|
|
extern int maxCopCars;
|
|
|
|
extern int maxCivCars;
|
|
|
|
|
|
|
|
sprintf(tempBuf, "Civs: %d - %d parked - max %d", numCivCars, numParkedCars, maxCivCars);
|
2020-08-26 15:50:03 +02:00
|
|
|
PrintString(tempBuf, 10, 40);
|
2020-05-27 13:04:24 +02:00
|
|
|
|
|
|
|
sprintf(tempBuf, "Cops: %d - %d active - max %d", numCopCars, numActiveCops, maxCopCars);
|
2020-08-26 15:50:03 +02:00
|
|
|
PrintString(tempBuf, 10, 50);
|
2020-08-25 10:18:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
int playerCar = player[0].playerCarId;
|
|
|
|
int speed = car_data[playerCar].hd.speed;
|
|
|
|
|
2020-08-26 15:50:03 +02:00
|
|
|
sprintf(tempBuf, "Car speed: %d", speed);
|
|
|
|
PrintString(tempBuf, 10, 60);
|
2020-10-08 17:25:40 +02:00
|
|
|
|
|
|
|
sprintf(tempBuf, "Mission %d Chase: %d", gCurrentMissionNumber, gRandomChase);
|
|
|
|
PrintString(tempBuf, 10, 70);
|
2020-05-06 13:22:54 +02:00
|
|
|
}
|
2020-05-01 10:51:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Debug_AddLine(VECTOR& pointA, VECTOR& pointB, CVECTOR& color)
|
|
|
|
{
|
2020-05-06 12:12:06 +02:00
|
|
|
if (gDebug_numLines + 1 > 512)
|
|
|
|
return;
|
|
|
|
|
2020-06-24 16:35:03 +02:00
|
|
|
int dx = camera_position.vx - pointA.vx;
|
|
|
|
int dz = camera_position.vz - pointA.vz;
|
|
|
|
|
|
|
|
if (dx * dx + dz * dz > (15000*15000))
|
|
|
|
return;
|
|
|
|
|
2020-05-01 10:51:44 +02:00
|
|
|
LineDef_t& ld = gDebug_Lines[gDebug_numLines++];
|
|
|
|
ld.posA = pointA;
|
|
|
|
ld.posB = pointB;
|
|
|
|
ld.color = color;
|
2020-05-02 05:11:44 +02:00
|
|
|
|
|
|
|
ld.posA.vy *= -1;
|
|
|
|
ld.posB.vy *= -1;
|
|
|
|
}
|
|
|
|
|
2020-10-24 19:38:33 +02:00
|
|
|
void Debug_Line2D(SXYPAIR& pointA, SXYPAIR& pointB, CVECTOR& color)
|
|
|
|
{
|
|
|
|
LINE_F2* line = (LINE_F2*)current->primptr;
|
|
|
|
setLineF2(line);
|
|
|
|
|
|
|
|
line->x0 = pointA.x;
|
|
|
|
line->y0 = pointA.y;
|
|
|
|
|
|
|
|
line->x1 = pointB.x;
|
|
|
|
line->y1 = pointB.y;
|
|
|
|
|
|
|
|
line->r0 = color.r;
|
|
|
|
line->g0 = color.g;
|
|
|
|
line->b0 = color.b;
|
|
|
|
|
|
|
|
addPrim(current->ot, line);
|
|
|
|
|
|
|
|
current->primptr += sizeof(LINE_F2);
|
|
|
|
}
|
|
|
|
|
2020-05-02 05:11:44 +02:00
|
|
|
void Debug_AddLineOfs(VECTOR& pointA, VECTOR& pointB, VECTOR& ofs, CVECTOR& color)
|
|
|
|
{
|
2020-05-06 12:12:06 +02:00
|
|
|
if (gDebug_numLines + 1 > 512)
|
|
|
|
return;
|
|
|
|
|
2020-06-24 16:35:03 +02:00
|
|
|
int dx = camera_position.vx - ofs.vx;
|
|
|
|
int dz = camera_position.vz - ofs.vz;
|
|
|
|
|
|
|
|
if (dx * dx + dz * dz > (15000 * 15000))
|
|
|
|
return;
|
|
|
|
|
2020-05-02 05:11:44 +02:00
|
|
|
LineDef_t& ld = gDebug_Lines[gDebug_numLines++];
|
|
|
|
ld.posA = pointA;
|
|
|
|
ld.posB = pointB;
|
|
|
|
ld.color = color;
|
|
|
|
|
|
|
|
ld.posA.vx += ofs.vx;
|
|
|
|
ld.posA.vy += ofs.vy;
|
|
|
|
ld.posA.vz += ofs.vz;
|
|
|
|
|
|
|
|
ld.posB.vx += ofs.vx;
|
|
|
|
ld.posB.vy += ofs.vy;
|
|
|
|
ld.posB.vz += ofs.vz;
|
|
|
|
|
|
|
|
ld.posA.vy *= -1;
|
|
|
|
ld.posB.vy *= -1;
|
2020-08-25 10:18:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int g_FreeCameraControls = 0;
|
|
|
|
int g_FreeCameraEnabled = 0;
|
|
|
|
VECTOR g_FreeCameraPosition;
|
|
|
|
SVECTOR g_FreeCameraRotation;
|
|
|
|
VECTOR g_FreeCameraVelocity;
|
|
|
|
extern int cursorX, cursorY, cursorOldX, cursorOldY;
|
|
|
|
|
|
|
|
extern VECTOR lis_pos;
|
|
|
|
|
2020-09-02 19:03:58 +02:00
|
|
|
void BuildFreeCameraMatrix()
|
|
|
|
{
|
|
|
|
if (g_FreeCameraEnabled == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
player[0].cameraPos = g_FreeCameraPosition;
|
|
|
|
camera_position = g_FreeCameraPosition;
|
|
|
|
camera_angle = g_FreeCameraRotation;
|
|
|
|
lis_pos = camera_position;
|
|
|
|
|
|
|
|
BuildWorldMatrix();
|
|
|
|
}
|
|
|
|
|
2020-08-25 10:18:56 +02:00
|
|
|
void DoFreeCamera()
|
|
|
|
{
|
|
|
|
if (g_FreeCameraEnabled == 0)
|
|
|
|
{
|
|
|
|
g_FreeCameraPosition = camera_position;
|
|
|
|
g_FreeCameraRotation = camera_angle;
|
|
|
|
g_FreeCameraVelocity.vx = 0;
|
|
|
|
g_FreeCameraVelocity.vy = 0;
|
|
|
|
g_FreeCameraVelocity.vz = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-02 19:03:58 +02:00
|
|
|
BuildFreeCameraMatrix();
|
2020-08-25 10:18:56 +02:00
|
|
|
|
2020-09-11 11:30:58 +02:00
|
|
|
g_FreeCameraPosition.vx += FIXEDH(g_FreeCameraVelocity.vx);
|
|
|
|
g_FreeCameraPosition.vy += FIXEDH(g_FreeCameraVelocity.vy);
|
|
|
|
g_FreeCameraPosition.vz += FIXEDH(g_FreeCameraVelocity.vz);
|
2020-08-25 10:18:56 +02:00
|
|
|
|
|
|
|
// deaccel
|
2020-08-25 18:18:14 +02:00
|
|
|
g_FreeCameraVelocity.vx -= (g_FreeCameraVelocity.vx / 8);
|
|
|
|
g_FreeCameraVelocity.vy -= (g_FreeCameraVelocity.vy / 8);
|
|
|
|
g_FreeCameraVelocity.vz -= (g_FreeCameraVelocity.vz / 8);
|
2020-08-25 10:18:56 +02:00
|
|
|
|
|
|
|
// accel
|
|
|
|
if ((g_FreeCameraControls & 0x1) || (g_FreeCameraControls & 0x2)) // forward/back
|
|
|
|
{
|
|
|
|
int sign = (g_FreeCameraControls & 0x2) ? -1 : 1;
|
|
|
|
|
|
|
|
g_FreeCameraVelocity.vx += (inv_camera_matrix.m[2][0] * 32) * sign;
|
|
|
|
g_FreeCameraVelocity.vy += (inv_camera_matrix.m[2][1] * 32) * sign;
|
|
|
|
g_FreeCameraVelocity.vz += (inv_camera_matrix.m[2][2] * 32) * sign;
|
|
|
|
}
|
|
|
|
|
|
|
|
// side
|
|
|
|
if ((g_FreeCameraControls & 0x4) || (g_FreeCameraControls & 0x8)) // right/left
|
|
|
|
{
|
|
|
|
int sign = (g_FreeCameraControls & 0x8) ? 1 : -1;
|
|
|
|
|
|
|
|
g_FreeCameraVelocity.vx += (inv_camera_matrix.m[0][0] * 32) * sign;
|
|
|
|
g_FreeCameraVelocity.vy += (inv_camera_matrix.m[0][1] * 32) * sign;
|
|
|
|
g_FreeCameraVelocity.vz += (inv_camera_matrix.m[0][2] * 32) * sign;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-01 10:51:44 +02:00
|
|
|
}
|