2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_math.S
|
|
|
|
|
|
|
|
Client x86 assembly-language math routines.
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
2001-05-31 05:33:13 +00:00
|
|
|
#include "asm_i386.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "quakeasm.h"
|
|
|
|
|
2001-06-11 20:59:48 +00:00
|
|
|
#ifdef PIC
|
2001-05-25 22:57:25 +00:00
|
|
|
#undef USE_INTEL_ASM //XXX asm pic hack
|
2001-06-11 20:59:48 +00:00
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#ifdef USE_INTEL_ASM
|
|
|
|
|
|
|
|
.data
|
|
|
|
|
|
|
|
.text
|
|
|
|
|
|
|
|
// TODO: rounding needed?
|
|
|
|
// stack parameter offset
|
|
|
|
#define val 4
|
|
|
|
|
|
|
|
.globl C(Invert24To16)
|
|
|
|
C(Invert24To16):
|
|
|
|
|
|
|
|
movl val(%esp),%ecx
|
|
|
|
movl $0x100,%edx // 0x10000000000 as dividend
|
|
|
|
cmpl %edx,%ecx
|
|
|
|
jle LOutOfRange
|
|
|
|
|
|
|
|
subl %eax,%eax
|
|
|
|
divl %ecx
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
LOutOfRange:
|
|
|
|
movl $0xFFFFFFFF,%eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
#define in 4
|
|
|
|
#define out 8
|
|
|
|
|
|
|
|
.align 2
|
|
|
|
.globl C(TransformVector)
|
|
|
|
C(TransformVector):
|
|
|
|
movl in(%esp),%eax
|
|
|
|
movl out(%esp),%edx
|
|
|
|
|
|
|
|
flds (%eax) // in[0]
|
|
|
|
fmuls C(vright) // in[0]*vright[0]
|
|
|
|
flds (%eax) // in[0] | in[0]*vright[0]
|
|
|
|
fmuls C(vup) // in[0]*vup[0] | in[0]*vright[0]
|
|
|
|
flds (%eax) // in[0] | in[0]*vup[0] | in[0]*vright[0]
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
fmuls C(vfwd) // in[0]*vfwd[0] | in[0]*vup[0] | in[0]*vright[0]
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
flds 4(%eax) // in[1] | ...
|
|
|
|
fmuls C(vright)+4 // in[1]*vright[1] | ...
|
|
|
|
flds 4(%eax) // in[1] | in[1]*vright[1] | ...
|
|
|
|
fmuls C(vup)+4 // in[1]*vup[1] | in[1]*vright[1] | ...
|
|
|
|
flds 4(%eax) // in[1] | in[1]*vup[1] | in[1]*vright[1] | ...
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
fmuls C(vfwd)+4 // in[1]*vfwd[1] | in[1]*vup[1] | in[1]*vright[1] | ...
|
|
|
|
fxch %st(2) // in[1]*vright[1] | in[1]*vup[1] | in[1]*vfwd[1] | ...
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
faddp %st(0),%st(5) // in[1]*vup[1] | in[1]*vfwd[1] | ...
|
|
|
|
faddp %st(0),%st(3) // in[1]*vfwd[1] | ...
|
|
|
|
faddp %st(0),%st(1) // vfwd | vup_accum | vright_accum
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
flds 8(%eax) // in[2] | ...
|
|
|
|
fmuls C(vright)+8 // in[2]*vright[2] | ...
|
|
|
|
flds 8(%eax) // in[2] | in[2]*vright[2] | ...
|
|
|
|
fmuls C(vup)+8 // in[2]*vup[2] | in[2]*vright[2] | ...
|
|
|
|
flds 8(%eax) // in[2] | in[2]*vup[2] | in[2]*vright[2] | ...
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
fmuls C(vfwd)+8 // in[2]*vfwd[2] | in[2]*vup[2] | in[2]*vright[2] | ...
|
|
|
|
fxch %st(2) // in[2]*vright[2] | in[2]*vup[2] | in[2]*vfwd[2] | ...
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
faddp %st(0),%st(5) // in[2]*vup[2] | in[2]*vfwd[2] | ...
|
|
|
|
faddp %st(0),%st(3) // in[2]*vfwd[2] | ...
|
|
|
|
faddp %st(0),%st(1) // vfwd | vup_accum | vright_accum
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
fstps 8(%edx) // out[2]
|
|
|
|
fstps 4(%edx) // out[1]
|
|
|
|
fstps (%edx) // out[0]
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
#endif // USE_INTEL_ASM
|
2021-06-13 14:12:03 +00:00
|
|
|
|
|
|
|
#if defined(__linux__) && defined(__ELF__)
|
|
|
|
.section .note.GNU-stack,"",%progbits
|
|
|
|
#endif
|