Feature/collision detection (#60)

* most functions implemented, car disappears on collision?
* implements friction from collision, car no longer disappears
* removes -Werror compiler flag for DETHRACE directory
This commit is contained in:
Jeff Harris 2021-09-21 13:09:18 +12:00 committed by GitHub
parent 9ac6479f34
commit 4608bdd8ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 1442 additions and 158 deletions

View File

@ -1,10 +1,36 @@
#include "matrix4.h"
#include "harness_trace.h"
#include <math.h>
#define A(x, y) A->m[x][y]
#define B(x, y) B->m[x][y]
#define C(x, y) C->m[x][y]
#define M(x, y) mat->m[x][y]
#define BR_MAC2(a, b, c, d) ((a) * (b) + (c) * (d))
#define BR_MAC3(a, b, c, d, e, f) ((a) * (b) + (c) * (d) + (e) * (f))
#define BR_MAC4(a, b, c, d, e, f, g, h) ((a) * (b) + (c) * (d) + (e) * (f) + (g) * (h))
// IDA: void __cdecl BrMatrix4Copy(br_matrix4 *A, br_matrix4 *B)
void BrMatrix4Copy(br_matrix4* A, br_matrix4* B) {
LOG_TRACE("(%p, %p)", A, B);
NOT_IMPLEMENTED();
A(0, 0) = B(0, 0);
A(0, 1) = B(0, 1);
A(0, 2) = B(0, 2);
A(0, 3) = B(0, 3);
A(1, 0) = B(1, 0);
A(1, 1) = B(1, 1);
A(1, 2) = B(1, 2);
A(1, 3) = B(1, 3);
A(2, 0) = B(2, 0);
A(2, 1) = B(2, 1);
A(2, 2) = B(2, 2);
A(2, 3) = B(2, 3);
A(3, 0) = B(3, 0);
A(3, 1) = B(3, 1);
A(3, 2) = B(3, 2);
A(3, 3) = B(3, 3);
}
// IDA: void __cdecl BrMatrix4Mul(br_matrix4 *A, br_matrix4 *B, br_matrix4 *C)
@ -32,13 +58,30 @@ br_scalar BrMatrix4Inverse(br_matrix4* A, br_matrix4* B) {
br_scalar det;
br_scalar idet;
LOG_TRACE("(%p, %p)", A, B);
NOT_IMPLEMENTED();
BrMatrix4Adjoint(A, B);
det = BrMatrix4Determinant(B);
if (fabs(det) < BR_SCALAR_EPSILON * 2)
return 0;
idet = 1.0 / det;
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
A(i, j) = A(i, j) * idet;
}
}
return det;
}
// IDA: br_scalar __cdecl Determinant3(br_scalar a1, br_scalar a2, br_scalar a3, br_scalar b1, br_scalar b2, br_scalar b3, br_scalar c1, br_scalar c2, br_scalar c3)
br_scalar Determinant3(br_scalar a1, br_scalar a2, br_scalar a3, br_scalar b1, br_scalar b2, br_scalar b3, br_scalar c1, br_scalar c2, br_scalar c3) {
LOG_TRACE("(%f, %f, %f, %f, %f, %f, %f, %f, %f)", a1, a2, a3, b1, b2, b3, c1, c2, c3);
NOT_IMPLEMENTED();
return BR_MAC3(a1, BR_MAC2(b2, c3, -b3, c2),
-b1, BR_MAC2(a2, c3, -a3, c2),
c1, BR_MAC2(a2, b3, -a3, b2));
}
// IDA: br_scalar __cdecl BrMatrix4Determinant(br_matrix4 *mat)
@ -60,7 +103,31 @@ br_scalar BrMatrix4Determinant(br_matrix4* mat) {
br_scalar d3;
br_scalar d4;
LOG_TRACE("(%p)", mat);
NOT_IMPLEMENTED();
a1 = M(0, 0);
b1 = M(0, 1);
c1 = M(0, 2);
d1 = M(0, 3);
a2 = M(1, 0);
b2 = M(1, 1);
c2 = M(1, 2);
d2 = M(1, 3);
a3 = M(2, 0);
b3 = M(2, 1);
c3 = M(2, 2);
d3 = M(2, 3);
a4 = M(3, 0);
b4 = M(3, 1);
c4 = M(3, 2);
d4 = M(3, 3);
return BR_MAC4(a1, Determinant3(b2, b3, b4, c2, c3, c4, d2, d3, d4),
-b1, Determinant3(a2, a3, a4, c2, c3, c4, d2, d3, d4),
c1, Determinant3(a2, a3, a4, b2, b3, b4, d2, d3, d4),
-d1, Determinant3(a2, a3, a4, b2, b3, b4, c2, c3, c4));
}
// IDA: void __cdecl BrMatrix4Adjoint(br_matrix4 *A, br_matrix4 *B)
@ -82,7 +149,48 @@ void BrMatrix4Adjoint(br_matrix4* A, br_matrix4* B) {
br_scalar d3;
br_scalar d4;
LOG_TRACE("(%p, %p)", A, B);
NOT_IMPLEMENTED();
a1 = B(0, 0);
b1 = B(0, 1);
c1 = B(0, 2);
d1 = B(0, 3);
a2 = B(1, 0);
b2 = B(1, 1);
c2 = B(1, 2);
d2 = B(1, 3);
a3 = B(2, 0);
b3 = B(2, 1);
c3 = B(2, 2);
d3 = B(2, 3);
a4 = B(3, 0);
b4 = B(3, 1);
c4 = B(3, 2);
d4 = B(3, 3);
/* row column labeling reversed since we transpose rows & columns */
A(0, 0) = Determinant3(b2, b3, b4, c2, c3, c4, d2, d3, d4);
A(1, 0) = -Determinant3(a2, a3, a4, c2, c3, c4, d2, d3, d4);
A(2, 0) = Determinant3(a2, a3, a4, b2, b3, b4, d2, d3, d4);
A(3, 0) = -Determinant3(a2, a3, a4, b2, b3, b4, c2, c3, c4);
A(0, 1) = -Determinant3(b1, b3, b4, c1, c3, c4, d1, d3, d4);
A(1, 1) = Determinant3(a1, a3, a4, c1, c3, c4, d1, d3, d4);
A(2, 1) = -Determinant3(a1, a3, a4, b1, b3, b4, d1, d3, d4);
A(3, 1) = Determinant3(a1, a3, a4, b1, b3, b4, c1, c3, c4);
A(0, 2) = Determinant3(b1, b2, b4, c1, c2, c4, d1, d2, d4);
A(1, 2) = -Determinant3(a1, a2, a4, c1, c2, c4, d1, d2, d4);
A(2, 2) = Determinant3(a1, a2, a4, b1, b2, b4, d1, d2, d4);
A(3, 2) = -Determinant3(a1, a2, a4, b1, b2, b4, c1, c2, c4);
A(0, 3) = -Determinant3(b1, b2, b3, c1, c2, c3, d1, d2, d3);
A(1, 3) = Determinant3(a1, a2, a3, c1, c2, c3, d1, d2, d3);
A(2, 3) = -Determinant3(a1, a2, a3, b1, b2, b3, d1, d2, d3);
A(3, 3) = Determinant3(a1, a2, a3, b1, b2, b3, c1, c2, c3);
}
// IDA: void __cdecl BrMatrix4Perspective(br_matrix4 *mat, br_angle field_of_view, br_scalar aspect, br_scalar hither, br_scalar yon)
@ -113,7 +221,11 @@ void BrMatrix4ApplyV(br_vector4* A, br_vector3* B, br_matrix4* C) {
// IDA: void __cdecl BrMatrix4TApply(br_vector4 *A, br_vector4 *B, br_matrix4 *C)
void BrMatrix4TApply(br_vector4* A, br_vector4* B, br_matrix4* C) {
LOG_TRACE("(%p, %p, %p)", A, B, C);
NOT_IMPLEMENTED();
A->v[0] = BR_MAC4(B->v[0], C(0, 0), B->v[1], C(0, 1), B->v[2], C(0, 2), B->v[3], C(0, 3));
A->v[1] = BR_MAC4(B->v[0], C(1, 0), B->v[1], C(1, 1), B->v[2], C(1, 2), B->v[3], C(1, 3));
A->v[2] = BR_MAC4(B->v[0], C(2, 0), B->v[1], C(2, 1), B->v[2], C(2, 2), B->v[3], C(2, 3));
A->v[3] = BR_MAC4(B->v[0], C(3, 0), B->v[1], C(3, 1), B->v[2], C(3, 2), B->v[3], C(3, 3));
}
// IDA: void __cdecl BrMatrix4TApplyP(br_vector4 *A, br_vector3 *B, br_matrix4 *C)

View File

@ -14,11 +14,11 @@ int BrMemCmp(void* s1, void* s2, size_t n) {
}
void* BrMemCpy(void* s1, void* s2, size_t n) {
memcpy(s1, s2, n);
return memcpy(s1, s2, n);
}
void* BrMemSet(void* s, int c, size_t n) {
memset(s, c, n);
return memset(s, c, n);
}
char* BrStrCat(char* s1, char* s2) {
@ -65,62 +65,50 @@ char* BrStrNCpy(char* s1, char* s2, size_t n) {
char* BrStrRChr(char* s1, char c) {
return strrchr(s1, c);
NOT_IMPLEMENTED();
}
void BrAbort(void) {
abort();
NOT_IMPLEMENTED();
}
char* BrGetEnv(char* name) {
return getenv(name);
NOT_IMPLEMENTED();
}
float BrStrToF(char* nptr, char** endptr) {
return strtof(nptr, endptr);
NOT_IMPLEMENTED();
}
double BrStrToD(char* nptr, char** endptr) {
return strtod(nptr, endptr);
NOT_IMPLEMENTED();
}
long BrStrToL(char* nptr, char** endptr, int base) {
return strtol(nptr, endptr, base);
NOT_IMPLEMENTED();
}
unsigned long BrStrToUL(char* nptr, char** endptr, int base) {
return strtoul(nptr, endptr, base);
NOT_IMPLEMENTED();
}
br_boolean BrIsAlpha(int c) {
return isalpha(c);
NOT_IMPLEMENTED();
}
br_boolean BrIsDigit(int c) {
return isdigit(c);
NOT_IMPLEMENTED();
}
br_boolean BrIsSpace(int c) {
return isspace(c);
NOT_IMPLEMENTED();
}
br_boolean BrIsPrint(int c) {
return isprint(c);
NOT_IMPLEMENTED();
}
br_int_32 BrVSprintf(char* buf, const char* fmt, va_list args) {
return vsprintf(buf, fmt, args);
NOT_IMPLEMENTED();
}
br_int_32 BrVSprintfN(char* buf, br_size_t buf_size, const char* fmt, va_list args) {
@ -140,5 +128,4 @@ br_int_32 BrVSprintfN(char* buf, br_size_t buf_size, const char* fmt, va_list ar
br_int_32 BrVSScanf(char* buf, const char* fmt, va_list args) {
return vsscanf(buf, fmt, args);
NOT_IMPLEMENTED();
}

View File

@ -17,5 +17,5 @@ void BrBufferUpdate(br_pixelmap* pm, br_token use, br_uint_16 flags) {
void BrBufferClear(br_pixelmap* pm) {
LOG_TRACE("(%p)", pm);
SILENT_STUB();
STUB_ONCE();
}

View File

@ -53,7 +53,7 @@ void BrMaterialFree(br_material* m);
br_uint_32 BrMaterialAddMany(br_material** items, int n);
br_uint_32 BrMaterialEnum(char* pattern, br_material_enum_cbfn* callback, void* arg);
// BrMatrix
// BrMatrix34
void BrMatrix23Identity(br_matrix23* mat);
void BrMatrix34Identity(br_matrix34* mat);
@ -81,6 +81,11 @@ void BrMatrix34PostShearX(br_matrix34* mat, br_scalar sy, br_scalar sz);
void BrMatrix34PostShearY(br_matrix34* mat, br_scalar sx, br_scalar sz);
void BrMatrix34PostShearZ(br_matrix34* mat, br_scalar sx, br_scalar sy);
// BrMatrix4
void BrMatrix4Copy(br_matrix4* A, br_matrix4* B);
br_scalar BrMatrix4Inverse(br_matrix4* A, br_matrix4* B);
void BrMatrix4TApply(br_vector4* A, br_vector4* B, br_matrix4* C);
// BrMem
void BrMemFree(void* block);
void* BrMemAllocate(br_size_t size, br_uint_8 type);

View File

@ -17,7 +17,6 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang")
target_compile_options(dethrace_obj PRIVATE
-g
-Wall
-Werror
-Wno-return-type
-Wno-unused-variable
-Wno-unused-parameter
@ -28,7 +27,6 @@ elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(dethrace_obj PRIVATE
-g
-Wall
-Werror
-Wno-return-type
-Wno-unused-variable
-Wno-unused-parameter

File diff suppressed because it is too large Load Diff

View File

@ -163,7 +163,7 @@ void FinishLap(int i) {
// IDA: void __cdecl EnsureSpecialVolumesHidden()
void EnsureSpecialVolumesHidden() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl ShowSpecialVolumesIfRequ()
@ -691,7 +691,7 @@ void CheckRecoveryOfCars(tU32 pEndFrameTime) {
int time;
char s[256];
LOG_TRACE("(%d)", pEndFrameTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall LoseSomePSPowerups(int pNumber@<EAX>)
@ -722,7 +722,7 @@ void CheckOtherRacingKeys() {
static int stopped_repairing;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: int __cdecl CheckRecoverCost()
@ -1054,7 +1054,7 @@ void ToggleMap() {
static int old_indent;
static int was_in_cockpit;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: int __cdecl HornBlowing()
@ -1250,7 +1250,7 @@ void EnterUserMessage() {
int the_key;
int abuse_num;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl DisplayUserMessage()

View File

@ -249,7 +249,7 @@ void RecordLastDamage(tCar_spec* pCar) {
int i;
LOG_TRACE("(%p)", pCar);
STUB();
STUB_ONCE();
}
// IDA: void __usercall DoDamage(tCar_spec *pCar@<EAX>, tDamage_type pDamage_type@<EDX>, float pMagnitude, float pNastiness)
@ -328,7 +328,7 @@ void SetSmokeLastDamageLevel(tCar_spec* pCar) {
int i;
LOG_TRACE("(%p)", pCar);
STUB();
STUB_ONCE();
}
// IDA: void __usercall SortOutSmoke(tCar_spec *pCar@<EAX>)
@ -404,11 +404,11 @@ void DoWheelDamage(tU32 pFrame_period) {
br_vector3 wonky_vector;
static int kev_index[4];
LOG_TRACE("(%d)", pFrame_period);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall CrashEarnings(tCar_spec *pCar1@<EAX>, tCar_spec *pCar2@<EDX>)
void CrashEarnings(tCar_spec* pCar1, tCar_spec* pCar2) {
LOG_TRACE("(%p, %p)", pCar1, pCar2);
NOT_IMPLEMENTED();
STUB();
}

View File

@ -344,13 +344,13 @@ void DoFog(br_pixelmap* pRender_buffer, br_pixelmap* pDepth_buffer) {
// IDA: void __usercall DepthEffect(br_pixelmap *pRender_buffer@<EAX>, br_pixelmap *pDepth_buffer@<EDX>, br_actor *pCamera@<EBX>, br_matrix34 *pCamera_to_world@<ECX>)
void DepthEffect(br_pixelmap* pRender_buffer, br_pixelmap* pDepth_buffer, br_actor* pCamera, br_matrix34* pCamera_to_world) {
LOG_TRACE("(%p, %p, %p, %p)", pRender_buffer, pDepth_buffer, pCamera, pCamera_to_world);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall DepthEffectSky(br_pixelmap *pRender_buffer@<EAX>, br_pixelmap *pDepth_buffer@<EDX>, br_actor *pCamera@<EBX>, br_matrix34 *pCamera_to_world@<ECX>)
void DepthEffectSky(br_pixelmap* pRender_buffer, br_pixelmap* pDepth_buffer, br_actor* pCamera, br_matrix34* pCamera_to_world) {
LOG_TRACE("(%p, %p, %p, %p)", pRender_buffer, pDepth_buffer, pCamera, pCamera_to_world);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall DoWobbleCamera(br_actor *pCamera@<EAX>)
@ -406,7 +406,7 @@ void DoDrugWobbleCamera(br_actor* pCamera) {
// IDA: void __usercall DoSpecialCameraEffect(br_actor *pCamera@<EAX>, br_matrix34 *pCamera_to_world@<EDX>)
void DoSpecialCameraEffect(br_actor* pCamera, br_matrix34* pCamera_to_world) {
LOG_TRACE("(%p, %p)", pCamera, pCamera_to_world);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl LessDepthFactor()
@ -622,7 +622,7 @@ void ChangeDepthEffect() {
br_scalar distance;
tSpecial_volume* special_volume;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl MungeForwardSky()

View File

@ -219,7 +219,7 @@ void DimRectangle(br_pixelmap* pPixelmap, int pLeft, int pTop, int pRight, int p
int line_skip;
int width;
LOG_TRACE9("(%p, %d, %d, %d, %d, %d)", pPixelmap, pLeft, pTop, pRight, pBottom, pKnock_out_corners);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl DimAFewBits()
@ -264,7 +264,7 @@ void DoPSPowerHeadup(int pY, int pLevel, char* pName, int pBar_colour) {
// IDA: void __cdecl DoPSPowerupHeadups()
void DoPSPowerupHeadups() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall DoHeadups(tU32 pThe_time@<EAX>)
@ -890,7 +890,7 @@ void DoDamageScreen(tU32 pThe_time) {
br_pixelmap* the_image;
tDamage_unit* the_damage;
LOG_TRACE("(%d)", pThe_time);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl PoshDrawLine(float pAngle, br_pixelmap *pDestn, int pX1, int pY1, int pX2, int pY2, int pColour)
@ -1147,14 +1147,14 @@ void DoSteeringWheel(tU32 pThe_time) {
br_pixelmap* hands_image;
int hands_index;
LOG_TRACE("(%d)", pThe_time);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl ChangingView()
void ChangingView() {
tU32 the_time;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall EarnCredits2(int pAmount@<EAX>, char *pPrefix_text@<EDX>)

View File

@ -419,7 +419,80 @@ void CheckSingleFace(tFace_ref* pFace, br_vector3* ray_pos, br_vector3* ray_dir,
double f_numerator;
br_material* this_material;
LOG_TRACE("(%p, %p, %p, %p, %p)", pFace, ray_pos, ray_dir, normal, rt);
NOT_IMPLEMENTED();
this_material = pFace->material;
*rt = 100.0;
d = pFace->normal.v[1] * ray_dir->v[1] + ray_dir->v[2] * pFace->normal.v[2] + ray_dir->v[0] * pFace->normal.v[0];
if ((!this_material || (this_material->flags & 0x1800) != 0 || d <= 0.0)
&& (!this_material || !this_material->identifier || *this_material->identifier != '!' || !gPling_materials)
&& fabs(d) >= 0.00000023841858) {
p.v[0] = ray_pos->v[0] - pFace->v[0].v[0];
p.v[1] = ray_pos->v[1] - pFace->v[0].v[1];
p.v[2] = ray_pos->v[2] - pFace->v[0].v[2];
numerator = pFace->normal.v[1] * p.v[1] + pFace->normal.v[2] * p.v[2] + pFace->normal.v[0] * p.v[0];
if (!BadDiv__finteray(numerator, d)) {
if (d > 0.0) {
if (-numerator < -0.001 || -numerator > d + 0.003) {
return;
}
} else if (numerator < -0.001 || 0.003 - d < numerator) {
return;
}
t = -(numerator / d);
if (t > 1.0) {
t = 1.0;
}
tv.v[0] = ray_dir->v[0] * t;
tv.v[1] = ray_dir->v[1] * t;
tv.v[2] = ray_dir->v[2] * t;
tv.v[0] = ray_pos->v[0] + tv.v[0];
tv.v[1] = ray_pos->v[1] + tv.v[1];
tv.v[2] = ray_pos->v[2] + tv.v[2];
axis_m = fabs(pFace->normal.v[0]) < fabs(pFace->normal.v[1]);
if (fabs(pFace->normal.v[2]) > fabs(pFace->normal.v[axis_m])) {
axis_m = 2;
}
if (axis_m) {
axis_0 = 0;
if (axis_m == 1) {
axis_1 = 2;
} else {
axis_1 = 1;
}
} else {
axis_0 = 1;
axis_1 = 2;
}
v0i1 = pFace->v[0].v[axis_0];
v0i2 = pFace->v[0].v[axis_1];
u0 = pFace->v[1].v[axis_0] - v0i1;
u1 = pFace->v[1].v[axis_1] - v0i2;
v0 = pFace->v[2].v[axis_0] - v0i1;
v1 = pFace->v[2].v[axis_1] - v0i2;
u2 = tv.v[axis_0] - v0i1;
v2 = tv.v[axis_1] - v0i2;
if (fabs(u0) > 0.0000002384185791015625) {
f_d = v1 * u0 - u1 * v0;
if (f_d == 0) {
return;
}
alpha = (v2 * u0 - u1 * u2) / f_d;
beta = (u2 - alpha * v0) / u0;
} else {
alpha = u2 / v0;
beta = (v2 - alpha * v1) / u1;
}
if (beta >= -0.0001 && alpha >= -0.0001 && alpha + beta <= 1.0001) {
*rt = t;
*normal = pFace->normal;
if (d > 0.0) {
normal->v[0] = -normal->v[0];
normal->v[1] = -normal->v[1];
normal->v[2] = -normal->v[2];
}
}
}
}
}
// IDA: void __usercall MultiRayCheckSingleFace(int pNum_rays@<EAX>, tFace_ref *pFace@<EDX>, br_vector3 *ray_pos@<EBX>, br_vector3 *ray_dir@<ECX>, br_vector3 *normal, br_scalar *rt)
@ -1071,7 +1144,59 @@ int LineBoxColl(br_vector3* o, br_vector3* p, br_bounds* pB, br_vector3* pHit_po
br_scalar max_t[3];
br_scalar cp[3];
LOG_TRACE("(%p, %p, %p, %p)", o, p, pB, pHit_point);
NOT_IMPLEMENTED();
inside = 1;
dir.v[0] = p->v[0] - o->v[0];
dir.v[1] = p->v[1] - o->v[1];
dir.v[2] = p->v[2] - o->v[2];
for (i = 0; i < 3; ++i) {
if (pB->min.v[i] <= o->v[i]) {
if (pB->max.v[i] >= o->v[i]) {
quad[i] = 2;
} else {
quad[i] = 0;
max_t[i] = pB->max.v[i];
inside = 0;
}
} else {
quad[i] = 1;
max_t[i] = pB->min.v[i];
inside = 0;
}
}
if (inside) {
*pHit_point = *o;
return 8;
} else {
for (i = 0; i < 3; ++i) {
if (quad[i] == 2 || dir.v[i] == 0.0) {
cp[i] = -1.0;
} else {
cp[i] = (max_t[i] - o->v[i]) / dir.v[i];
}
}
which_plane = 0;
for (i = 1; i < 3; ++i) {
if (cp[which_plane] < cp[i]) {
which_plane = i;
}
}
if (cp[which_plane] >= 0.0 && cp[which_plane] <= 1.0) {
for (i = 0; i < 3; ++i) {
if (which_plane == i) {
pHit_point->v[i] = max_t[i];
} else {
pHit_point->v[i] = dir.v[i] * cp[which_plane] + o->v[i];
if (pHit_point->v[i] < pB->min.v[i] || pB->max.v[i] < pHit_point->v[i]) {
return 0;
}
}
}
return which_plane + 4 * quad[which_plane] + 1;
} else {
return 0;
}
}
}
// IDA: int __usercall SphereBoxIntersection@<EAX>(br_bounds *pB@<EAX>, br_vector3 *pC@<EDX>, br_scalar pR_squared, br_vector3 *pHit_point)

View File

@ -196,7 +196,7 @@ void RenderLollipops() {
br_actor** the_actor;
br_actor* old_parent;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall DRDrawLine(br_pixelmap *pDestn@<EAX>, int pX1@<EDX>, int pY1@<EBX>, int pX2@<ECX>, int pY2, int pColour)
@ -625,7 +625,7 @@ void CalculateWobblitude(tU32 pThe_time) {
gScreen_wobble_x = 0;
gScreen_wobble_y = 0;
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall CalculateConcussion(tU32 pThe_time@<EAX>)
@ -640,7 +640,7 @@ void CalculateConcussion(tU32 pThe_time) {
LOG_TRACE("(%d)", pThe_time);
gConcussion.concussed = 0;
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl SufferFromConcussion(float pSeriousness)
@ -811,7 +811,7 @@ void RenderShadows(br_actor* pWorld, tTrack_spec* pTrack_spec, br_actor* pCamera
br_vector3 camera_to_car;
br_scalar distance_factor;
LOG_TRACE("(%p, %p, %p, %p)", pWorld, pTrack_spec, pCamera, pCamera_to_world_transform);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall FlashyMapCheckpoint(int pIndex@<EAX>, tU32 pTime@<EDX>)
@ -820,7 +820,7 @@ void FlashyMapCheckpoint(int pIndex, tU32 pTime) {
static tU32 last_flash;
static int flash_state;
LOG_TRACE("(%d, %d)", pIndex, pTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: int __usercall ConditionallyFillWithSky@<EAX>(br_pixelmap *pPixelmap@<EAX>)
@ -828,7 +828,7 @@ int ConditionallyFillWithSky(br_pixelmap* pPixelmap) {
int bgnd_col;
LOG_TRACE("(%p)", pPixelmap);
SILENT_STUB();
STUB_ONCE();
return 0;
}
@ -1375,7 +1375,7 @@ void ChangeAmbience(br_scalar pDelta) {
void InitAmbience() {
LOG_TRACE("()");
gCurrent_ambience = gAmbient_adjustment;
return ChangeAmbience(gAmbient_adjustment);
ChangeAmbience(gAmbient_adjustment);
}
// IDA: void __usercall DRPixelmapRectangleMaskedCopy(br_pixelmap *pDest@<EAX>, br_int_16 pDest_x@<EDX>, br_int_16 pDest_y@<EBX>, br_pixelmap *pSource@<ECX>, br_int_16 pSource_x, br_int_16 pSource_y, br_int_16 pWidth, br_int_16 pHeight)
@ -1580,7 +1580,7 @@ void DeallocateAllTransientBitmaps() {
void RemoveTransientBitmaps(int pGraphically_remove_them) {
int i;
int order_number;
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall SaveTransient(int pIndex@<EAX>, int pX_coord@<EDX>, int pY_coord@<EBX>)
@ -1635,7 +1635,8 @@ int DoMouseCursor() {
static int required_cursor;
static int zero_count;
static int button_was_down;
SILENT_STUB();
STUB_ONCE();
return 0;
}
// IDA: int __cdecl AllocateCursorTransient()

View File

@ -122,8 +122,6 @@ int gDemo_opponents[5];
int gDemo_power;
int gDemo_offensive;
#define DOUBLESIDED_FLAG_COLOR_MAP (br_pixelmap*)12345
// IDA: tU32 __usercall ReadU32@<EAX>(FILE *pF@<EAX>)
tU32 ReadU32(FILE* pF) {
tU32 raw_long;

View File

@ -151,7 +151,7 @@ void DoNetworkHeadups(int pCredits) {
static tU32 last_flash;
static int flash_state;
LOG_TRACE("(%d)", pCredits);
SILENT_STUB();
STUB_ONCE();
}
// IDA: int __usercall SortNetHeadAscending@<EAX>(void *pFirst_one@<EAX>, void *pSecond_one@<EDX>)
@ -295,7 +295,7 @@ void SendPlayerScores() {
// IDA: void __cdecl DoNetGameManagement()
void DoNetGameManagement() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall InitialisePlayerScore(tNet_game_player_info *pPlayer@<EAX>)
@ -381,7 +381,7 @@ void SendGameplayToAllPlayers(tNet_gameplay_mess pMess, int pParam_1, int pParam
tNet_message* the_message;
LOG_TRACE("(%d, %d, %d, %d, %d)", pMess, pParam_1, pParam_2, pParam_3, pParam_4);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall SendGameplayToHost(tNet_gameplay_mess pMess@<EAX>, int pParam_1@<EDX>, int pParam_2@<EBX>, int pParam_3@<ECX>, int pParam_4)

View File

@ -373,7 +373,7 @@ tNet_contents* NetGetBroadcastContents(tNet_message_type pType, tS32 pSize_decid
// IDA: void __cdecl NetSendMessageStacks()
void NetSendMessageStacks() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: tNet_message* __usercall NetAllocateMessage@<EAX>(int pSize@<EAX>)
@ -691,7 +691,7 @@ void NetReceiveAndProcessMessages() {
tU32 receive_time;
int old_net_service;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl BroadcastStatus()
@ -723,7 +723,7 @@ void CheckForPendingStartRace() {
void NetService(int pIn_race) {
tU32 time;
static tU32 last_status_broadcast;
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall NetFinishRace(tNet_game_details *pDetails@<EAX>, tRace_over_reason pReason@<EDX>)

View File

@ -166,7 +166,7 @@ void ProcessOilSpills(tU32 pFrame_period) {
br_vector3 v;
tNet_message* message;
LOG_TRACE("(%d)", pFrame_period);
SILENT_STUB();
STUB_ONCE();
}
// IDA: int __cdecl GetOilSpillCount()

View File

@ -916,7 +916,7 @@ void MungeOpponents(tU32 pFrame_period) {
int i;
int un_stun_flag;
LOG_TRACE("(%d)", pFrame_period);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl SetInitialCopPositions()

View File

@ -386,7 +386,7 @@ void MungePedestrianSequence(tPedestrian_data* pPedestrian, int pAction_changed)
float heading_difference;
tPedestrian_sequence* sequence_ptr;
LOG_TRACE("(%p, %d)", pPedestrian, pAction_changed);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall DetachPedFromCar(tPedestrian_data *pPedestrian@<EAX>)
@ -735,7 +735,7 @@ void MungePedestrians(tU32 pFrame_period) {
br_scalar z_delta;
tS32 diff;
LOG_TRACE("(%d)", pFrame_period);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl RespawnPedestrians()
@ -1581,7 +1581,7 @@ void RenderProximityRays(br_pixelmap* pRender_screen, br_pixelmap* pDepth_buffer
br_scalar distance;
br_scalar t;
LOG_TRACE("(%p, %p, %p, %p, %d)", pRender_screen, pDepth_buffer, pCamera, pCamera_to_world, pTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall AdjustProxRay(int pRay_index@<EAX>, tU16 pCar_ID@<EDX>, tU16 pPed_index@<EBX>, tU32 pTime@<ECX>)

View File

@ -101,7 +101,7 @@ void StartPipingSession2(tPipe_chunk_type pThe_type, int pMunge_reentrancy) {
void StartPipingSession(tPipe_chunk_type pThe_type) {
LOG_TRACE("(%d)", pThe_type);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall EndPipingSession2(int pMunge_reentrancy@<EAX>)
@ -115,7 +115,7 @@ void EndPipingSession2(int pMunge_reentrancy) {
void EndPipingSession() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall AddDataToSession(int pSubject_index@<EAX>, void *pData@<EDX>, tU32 pData_length@<EBX>)
@ -210,7 +210,7 @@ void AddSplashToPipingSession(tCollision_info* pCar) {
tPipe_splash_data data;
LOG_TRACE("(%p)", pCar);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall AddOilSpillToPipingSession(int pIndex@<EAX>, br_matrix34 *pMat@<EDX>, br_scalar pFull_size, br_scalar pGrow_rate, tU32 pSpill_time, tU32 pStop_time, tCar_spec *pCar, br_vector3 *pOriginal_pos, br_pixelmap *pPixelmap)
@ -379,7 +379,7 @@ void PipeSingleGrooveStop(int pGroove_index, br_matrix34* pMatrix, int pPath_int
// IDA: void __cdecl PipeFrameFinish()
void PipeFrameFinish() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl PipingFrameReset()
@ -404,7 +404,7 @@ void ResetPiping() {
// IDA: void __cdecl InitialisePiping()
void InitialisePiping() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl DisposePiping()
@ -466,7 +466,7 @@ void PipeCarPositions() {
tS8 damage_deltas[12];
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl ResetPipePlayToEnd()

View File

@ -162,7 +162,7 @@ void DrawPowerups(tU32 pTime) {
tHeadup_icon* the_icon;
br_pixelmap* fizzle_pix;
LOG_TRACE("(%d)", pTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall DoPowerupPeriodics(tU32 pFrame_period@<EAX>)
@ -171,7 +171,7 @@ void DoPowerupPeriodics(tU32 pFrame_period) {
tPowerup* the_powerup;
tU32 the_time;
LOG_TRACE("(%d)", pFrame_period);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall GotPowerupN(int pN@<EAX>)

View File

@ -20,7 +20,7 @@ int gCurrent_pratcam_alternative;
int PratcamGetCurrent() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
return 0;
}
@ -28,7 +28,7 @@ int PratcamGetCurrent() {
int PratcamGetAmbient() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
return 0;
}
@ -36,7 +36,7 @@ int PratcamGetAmbient() {
int PratcamGetPending() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
return 0;
}
@ -151,7 +151,7 @@ void DoPratcam(tU32 pThe_time) {
br_pixelmap* left_image;
br_pixelmap* right_image;
LOG_TRACE("(%d)", pThe_time);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall TestPratCam(int pIndex@<EAX>)

View File

@ -381,10 +381,7 @@ tSO_result DoAutoPartsShop() {
// IDA: void __cdecl SetOpponentFlic()
void SetOpponentFlic() {
LOG_TRACE("()");
return ChangePanelFlic(
0,
gOpponents[gCurrent_race.opponent_list[gOpponent_index].index].mug_shot_image_data,
gOpponents[gCurrent_race.opponent_list[gOpponent_index].index].mug_shot_image_data_length);
ChangePanelFlic(0, gOpponents[gCurrent_race.opponent_list[gOpponent_index].index].mug_shot_image_data, gOpponents[gCurrent_race.opponent_list[gOpponent_index].index].mug_shot_image_data_length);
}
// IDA: void __cdecl DrawSceneyMappyInfoVieweyThing()

View File

@ -91,7 +91,7 @@ void DoZappyActionReplayHeadups(int pSpecial_zappy_bastard) {
// IDA: void __cdecl DoActionReplayHeadups()
void DoActionReplayHeadups() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall MoveReplayBuffer(tS32 pMove_amount@<EAX>)
@ -123,7 +123,7 @@ void MoveToStartOfReplay() {
// IDA: void __cdecl ToggleReplay()
void ToggleReplay() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall ReverseSound(tS3_effect_tag pEffect_index@<EAX>, tS3_sound_tag pSound_tag@<EDX>)
@ -153,13 +153,13 @@ void PollActionReplayControls(tU32 pFrame_period) {
static int psuedo_mouse_keys[8];
static tRectangle mouse_areas[2][8];
LOG_TRACE("(%d)", pFrame_period);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl CheckReplayTurnOn()
void CheckReplayTurnOn() {
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl InitializeActionReplay()

View File

@ -166,7 +166,7 @@ void SkidMark(tCar_spec* pCar, int pWheel_num) {
br_material* material;
LOG_TRACE("(%p, %d)", pCar, pWheel_num);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall InitCarSkidStuff(tCar_spec *pCar@<EAX>)
@ -180,7 +180,7 @@ void InitCarSkidStuff(tCar_spec* pCar) {
void SkidsPerFrame() {
int skid;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl RemoveMaterialsFromSkidmarks()

View File

@ -83,6 +83,7 @@ tS3_sound_tag DRS3StartSound(tS3_outlet_ptr pOutlet, tS3_sound_id pSound) {
// IDA: tS3_sound_tag __usercall DRS3StartSoundNoPiping@<EAX>(tS3_outlet_ptr pOutlet@<EAX>, tS3_sound_id pSound@<EDX>)
tS3_sound_tag DRS3StartSoundNoPiping(tS3_outlet_ptr pOutlet, tS3_sound_id pSound) {
STUB();
return 0;
}
// IDA: tS3_sound_tag __usercall DRS3StartSound2@<EAX>(tS3_outlet_ptr pOutlet@<EAX>, tS3_sound_id pSound@<EDX>, tS3_repeats pRepeats@<EBX>, tS3_volume pLVolume@<ECX>, tS3_volume pRVolume, tS3_pitch pPitch, tS3_speed pSpeed)
@ -178,12 +179,14 @@ int DRS3OverallVolume(tS3_volume pVolume) {
// IDA: int __usercall DRS3StopOutletSound@<EAX>(tS3_outlet_ptr pOutlet@<EAX>)
int DRS3StopOutletSound(tS3_outlet_ptr pOutlet) {
STUB();
return 0;
}
// IDA: int __cdecl DRS3StopAllOutletSounds()
int DRS3StopAllOutletSounds() {
LOG_TRACE("()");
STUB();
return 0;
}
// IDA: void __cdecl ToggleSoundEnable()
@ -195,7 +198,7 @@ void ToggleSoundEnable() {
// IDA: void __cdecl SoundService()
void SoundService() {
br_matrix34 mat;
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl InitSoundSources()
@ -252,7 +255,7 @@ void MungeEngineNoise() {
int stop_all;
int type_of_engine_noise;
tS3_sound_id engine_noise;
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl SetSoundVolumes()

View File

@ -134,7 +134,7 @@ void RenderSparks(br_pixelmap* pRender_screen, br_pixelmap* pDepth_buffer, br_ac
br_vector3 new_pos;
br_scalar ts;
LOG_TRACE("(%p, %p, %p, %p, %d)", pRender_screen, pDepth_buffer, pCamera, pCamera_to_world, pTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall CreateSingleSpark(tCar_spec *pCar@<EAX>, br_vector3 *pPos@<EDX>, br_vector3 *pVel@<EBX>)
@ -155,7 +155,7 @@ void CreateSparks(br_vector3* pos, br_vector3* v, br_vector3* pForce, br_scalar
int num;
int i;
LOG_TRACE("(%p, %p, %p, %f, %p)", pos, v, pForce, sparkiness, pCar);
NOT_IMPLEMENTED();
STUB();
}
// IDA: void __usercall CreateSparkShower(br_vector3 *pos@<EAX>, br_vector3 *v@<EDX>, br_vector3 *pForce@<EBX>, tCar_spec *pCar1@<ECX>, tCar_spec *pCar2)
@ -259,7 +259,7 @@ void MungeShrapnel(tU32 pTime) {
br_matrix34* mat;
br_scalar ts;
LOG_TRACE("(%d)", pTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall DrMatrix34Rotate(br_matrix34 *mat@<EAX>, br_angle r@<EDX>, br_vector3 *a@<EBX>)
@ -380,7 +380,7 @@ void GenerateContinuousSmoke(tCar_spec* pCar, int wheel, tU32 pTime) {
int colour;
LOG_TRACE("(%p, %d, %d)", pCar, wheel, pTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl DustRotate()
@ -399,7 +399,7 @@ void RenderSmoke(br_pixelmap* pRender_screen, br_pixelmap* pDepth_buffer, br_act
tU32 seed;
tU32 not_lonely;
LOG_TRACE("(%p, %p, %p, %p, %d)", pRender_screen, pDepth_buffer, pCamera, pCamera_to_world, pTime);
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall CreatePuffOfSmoke(br_vector3 *pos@<EAX>, br_vector3 *v@<EDX>, br_scalar strength, br_scalar pDecay_factor, int pType, tCar_spec *pC)
@ -790,7 +790,7 @@ void MungeSplash(tU32 pTime) {
void RenderSplashes() {
int i;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall GetSmokeShadeTables(FILE *f@<EAX>)

View File

@ -113,7 +113,7 @@ void CheckCheckpoints() {
int car_index;
tNet_game_player_info* net_player;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __cdecl TotalRepair()

View File

@ -2563,7 +2563,7 @@ void FunkThoseTronics() {
float f_time_diff;
br_pixelmap* old_colour_map;
LOG_TRACE("()");
SILENT_STUB();
STUB_ONCE();
}
// IDA: void __usercall LollipopizeActor(br_actor *pSubject_actor@<EAX>, br_matrix34 *ref_to_world@<EDX>, tLollipop_mode pWhich_axis@<EBX>)

View File

@ -294,4 +294,10 @@ typedef enum keymapcodes {
#define OPPONENT_COUNT 0
#define WORLD_SCALE 6.9000001
#define DOUBLESIDED_FLAG_COLOR_MAP (br_pixelmap*)12345
#define SLOBYTE(x) (*((signed char*)&(x)))
#endif

View File

@ -54,12 +54,10 @@ void debug_print_matrix34(const char* fmt, const char* fn, char* name, br_matrix
debug_printf("\033[0;31m[PANIC] %s ", __FUNCTION__, "%s", "code path not expected"); \
exit(1);
#define STUB() \
if (harness_debug_level >= 5) { \
debug_printf("\033[0;31m[WARN] %s ", __FUNCTION__, "%s", "stubbed"); \
}
#define STUB() \
debug_printf("\033[0;31m[WARN] %s ", __FUNCTION__, "%s", "stubbed");
#define SILENT_STUB() \
#define STUB_ONCE() \
static int stub_printed = 0; \
if (!stub_printed) { \
debug_printf("\033[0;31m[WARN] %s ", __FUNCTION__, "%s", "stubbed"); \