shithub: qk1

Download patch

ref: 94202e45023d2d11d7cd88e3ab3366443e246a50
parent: a54ece93551f44af6fafb49363a1e0ac2e3f0bb2
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Sat Dec 16 19:30:47 EST 2023

move dotadd to BSP loading file; name math-specific files with m_* prefix

--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,6 @@
 	common.o\
 	console.o\
 	cvar.o\
-	dotadd.o\
 	d_alpha.o\
 	d_edge.o\
 	d_init.o\
@@ -35,12 +34,12 @@
 	d_sprite.o\
 	d_surf.o\
 	d_vars.o\
-	dotproduct.o\
 	draw.o\
 	fs.o\
 	host.o\
 	host_cmd.o\
 	keys.o\
+	m_dotproduct.o\
 	mathlib.o\
 	menu.o\
 	model.o\
--- a/dotadd.c
+++ /dev/null
@@ -1,19 +1,0 @@
-#include "quakedef.h"
-#include "softfloat.h"
-
-float
-dotadd(float *a, float *b)
-{
-	extFloat80_t x, y, m, z;
-	int i;
-
-	f32_to_extF80M(b[3], &z);
-	for(i = 0; i < 3; i++){
-		f32_to_extF80M(a[i], &x);
-		f32_to_extF80M(b[i], &y);
-		extF80M_mul(&x, &y, &m);
-		extF80M_add(&z, &m, &z);
-	}
-
-	return extF80M_to_f32(&z);;
-}
--- a/dotproduct.c
+++ /dev/null
@@ -1,7 +1,0 @@
-#include "quakedef.h"
-
-float
-DotProduct(const vec3_t v1, const vec3_t v2)
-{
-	return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
-}
--- a/dotproduct_arm64.s
+++ /dev/null
@@ -1,8 +1,0 @@
-TEXT DotProduct+0(SB), 1, $-4
-	MOV	v2+8(FP), R1
-	WORD $0x0d40a000 // ld3 {v0.s, v1.s, v2.s}[0], [x0]
-	WORD $0x0d40a023 // ld3 {v3.s, v4.s, v5.s}[0], [x1]
-	WORD $0x1e230800 // fmul s0, s0, s3
-	WORD $0x1f040020 // fmadd s0, s1, s4, s0
-	WORD $0x1f050040 // fmadd s0, s2, s5, s0
-	RETURN
--- /dev/null
+++ b/m_dotproduct.c
@@ -1,0 +1,7 @@
+#include "quakedef.h"
+
+float
+DotProduct(const vec3_t v1, const vec3_t v2)
+{
+	return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
+}
--- /dev/null
+++ b/m_dotproduct_arm64.s
@@ -1,0 +1,8 @@
+TEXT DotProduct+0(SB), 1, $-4
+	MOV	v2+8(FP), R1
+	WORD $0x0d40a000 // ld3 {v0.s, v1.s, v2.s}[0], [x0]
+	WORD $0x0d40a023 // ld3 {v3.s, v4.s, v5.s}[0], [x1]
+	WORD $0x1e230800 // fmul s0, s0, s3
+	WORD $0x1f040020 // fmadd s0, s1, s4, s0
+	WORD $0x1f050040 // fmadd s0, s2, s5, s0
+	RETURN
--- a/mkfile
+++ b/mkfile
@@ -7,7 +7,6 @@
 OFILES=\
 	span`{test -f span_$objtype.s && echo -n _$objtype}.$O\
 	span_alpha.$O\
-	dotproduct`{test -f span_$objtype.s && echo -n _$objtype}.$O\
 	cd.$O\
 	cl_demo.$O\
 	cl_input.$O\
@@ -19,7 +18,6 @@
 	common.$O\
 	console.$O\
 	cvar.$O\
-	dotadd.$O\
 	draw.$O\
 	d_alpha.$O\
 	d_edge.$O\
@@ -38,6 +36,7 @@
 	in.$O\
 	isnanf.$O\
 	keys.$O\
+	m_dotproduct`{test -f span_$objtype.s && echo -n _$objtype}.$O\
 	mathlib.$O\
 	menu.$O\
 	model.$O\
--- a/model_bsp.c
+++ b/model_bsp.c
@@ -1,7 +1,23 @@
 #include "quakedef.h"
+#include "softfloat.h"
 
-float dotadd(float *a, float *b);
+static float
+dotadd80(float *a, float *b)
+{
+	extFloat80_t x, y, m, z;
+	int i;
 
+	f32_to_extF80M(b[3], &z);
+	for(i = 0; i < 3; i++){
+		f32_to_extF80M(a[i], &x);
+		f32_to_extF80M(b[i], &y);
+		extF80M_mul(&x, &y, &m);
+		extF80M_add(&z, &m, &z);
+	}
+
+	return extF80M_to_f32(&z);;
+}
+
 void
 BSP_SetParent(mnode_t *node, mnode_t *parent)
 {
@@ -39,7 +55,7 @@
 			// but it's not 80 bits and stuff will still be broken.
 			// instead we literally run 80-bit calculation emulated
 			// using SoftFloat. enjoy. or not.
-			val = dotadd(v->position, tex->vecs[j]);
+			val = dotadd80(v->position, tex->vecs[j]);
 			if(val < mins[j])
 				mins[j] = val;
 			if(val > maxs[j])