Don't use assembly code for SV_HullPointContents.

This is the only assembly code dependent on the size of dclipnode_t.
Removing it paves the way for fixing clipnodes in large maps.
This commit is contained in:
Bill Currie 2010-11-29 08:51:29 +09:00
parent 2eda61931e
commit 995a8d3e4e
8 changed files with 11 additions and 343 deletions

View file

@ -157,7 +157,6 @@ typedef struct dplane_s {
#define CONTENTS_CURRENT_DOWN -14
// !!! if this is changed, it must be changed in asm_i386.h too !!!
typedef struct dnode_s {
int32_t planenum;
int16_t children[2]; // negative numbers are -(leafs+1), not nodes

View file

@ -67,14 +67,4 @@
#define hu_clip_maxs 28
#define hu_size 40
// dnode_t structure
// !!! if this is changed, it must be changed in bspfile.h too !!!
#define nd_planenum 0
#define nd_children 4
#define nd_mins 8
#define nd_maxs 20
#define nd_firstface 32
#define nd_numfaces 36
#define nd_size 40
#endif

View file

@ -44,17 +44,9 @@ bin_PROGRAMS= @NQ_TARGETS@
EXTRA_PROGRAMS= nq-fbdev nq-glx nq-mgl nq-sdl nq-sdl32 nq-sgl nq-svga nq-3dfx \
nq-wgl nq-x11 nq-server
if ASM_ARCH
asm= libasm.a
else
asm=
endif
noinst_LIBRARIES= @nq_libs@
EXTRA_LIBRARIES=libnq_client.a libnq_common.a libnq_sdl.a libnq_server.a
noinst_LIBRARIES= @nq_libs@ $(asm)
EXTRA_LIBRARIES=libasm.a libnq_client.a libnq_common.a libnq_sdl.a libnq_server.a
libasm_a_SOURCES= worlda.S
libasm_la_CCASFLAGS=@PREFER_NON_PIC@
libnq_common_a_SOURCES=game.c world.c com.c
libnq_sdl_a_SOURCES= sys_sdl.c
libnq_sdl_a_CFLAGS= $(SDL_CFLAGS)
@ -75,7 +67,6 @@ server_LIBFILES= \
$(top_builddir)/libs/models/libQFmodels.la
common_LIBFILES= \
$(asm) \
$(top_builddir)/libs/net/libnet_main.la \
$(top_builddir)/libs/console/libQFconsole.la \
$(top_builddir)/libs/gamecode/builtins/libQFgamecode_builtins.la \

View file

@ -431,7 +431,6 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
/* POINT TESTING IN HULLS */
#ifndef USE_INTEL_ASM
int
SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
{
@ -440,8 +439,8 @@ SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
mplane_t *plane;
while (num >= 0) {
if (num < hull->firstclipnode || num > hull->lastclipnode)
Sys_Error ("SV_HullPointContents: bad node number");
//if (num < hull->firstclipnode || num > hull->lastclipnode)
// Sys_Error ("SV_HullPointContents: bad node number");
node = hull->clipnodes + num;
plane = hull->planes + node->planenum;
@ -458,7 +457,6 @@ SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
return num;
}
#endif // !USE_INTEL_ASM
int
SV_PointContents (const vec3_t p)

View file

@ -1,150 +0,0 @@
/*
worlda.S
x86 assembly-language server testing stuff
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
#include "asm_i386.h"
//#include "quakeasm.h"
//include "d_ifacea.h"
#ifdef USE_INTEL_ASM
.data
Ltemp: .long 0
.text
//----------------------------------------------------------------------
// hull-point test
//----------------------------------------------------------------------
#define hull 4+8 // because only partially pushed
#define num 8+4 // because only partially pushed
#define p 12+12 // because only partially pushed
.align 4
.globl C(SV_HullPointContents)
C(SV_HullPointContents):
pushl %edi // preserve register variables
movl num(%esp),%eax
testl %eax,%eax
js Lhquickout
// float d;
// dclipnode_t *node;
// mplane_t *plane;
pushl %ebx
movl hull(%esp),%ebx
pushl %ebp
movl p(%esp),%edx
movl hu_clipnodes(%ebx),%edi
movl hu_planes(%ebx),%ebp
subl %ebx,%ebx
pushl %esi
// %ebx: 0
// %eax: num
// %edx: p
// %edi: hull->clipnodes
// %ebp: hull->planes
// while (num >= 0)
// {
Lhloop:
// node = hull->clipnodes + num;
// plane = hull->planes + node->planenum;
// !!! if the size of dclipnode_t changes, the scaling of %eax needs to be
// changed !!!
movl nd_planenum(%edi,%eax,8),%ecx
movl nd_children(%edi,%eax,8),%eax
movl %eax,%esi
rorl $16,%eax
leal (%ecx,%ecx,4),%ecx
// if (plane->type < 3)
// d = p[plane->type] - plane->dist;
movb pl_type(%ebp,%ecx,4),%bl
cmpb $3,%bl
jb Lnodot
// else
// d = DotProduct (plane->normal, p) - plane->dist;
flds pl_normal(%ebp,%ecx,4)
fmuls 0(%edx)
flds pl_normal+4(%ebp,%ecx,4)
fmuls 4(%edx)
flds pl_normal+8(%ebp,%ecx,4)
fmuls 8(%edx)
fxch %st(1)
faddp %st(0),%st(2)
faddp %st(0),%st(1)
fsubs pl_dist(%ebp,%ecx,4)
jmp Lsub
Lnodot:
flds pl_dist(%ebp,%ecx,4)
fsubrs (%edx,%ebx,4)
Lsub:
sarl $16,%eax
sarl $16,%esi
// if (d < 0)
// num = node->children[1];
// else
// num = node->children[0];
fstps Ltemp
movl Ltemp,%ecx
sarl $31,%ecx
andl %ecx,%esi
xorl $0xFFFFFFFF,%ecx
andl %ecx,%eax
orl %esi,%eax
jns Lhloop
// return num;
Lhdone:
popl %esi
popl %ebp
popl %ebx // restore register variables
Lhquickout:
popl %edi
ret
#endif // USE_INTEL_ASM

View file

@ -45,18 +45,10 @@ EXTRA_PROGRAMS= qw-client-fbdev qw-client-glx qw-client-mgl qw-client-sdl \
qw-client-sdl32 qw-client-sgl qw-client-svga qw-client-3dfx \
qw-client-wgl qw-client-x11 qw-server qw-master
if ASM_ARCH
asm= libasm.a
else
asm=
endif
noinst_LIBRARIES= @qw_libs@ $(asm)
EXTRA_LIBRARIES=libasm.a libqw_client.a libqw_common.a libqw_sdl.a libqw_server.a
noinst_LIBRARIES= @qw_libs@
EXTRA_LIBRARIES=libqw_client.a libqw_common.a libqw_sdl.a libqw_server.a
libasm_a_SOURCES= worlda.S
libasm_la_CCASFLAGS=@PREFER_NON_PIC@
libqw_common_a_SOURCES=\
com.c game.c map_cfg.c pmove.c pmovetst.c net_packetlog.c
libqw_sdl_a_SOURCES=cl_sys_sdl.c
@ -93,9 +85,9 @@ qw_server_LIBS= \
$(top_builddir)/libs/util/libQFutil.la
qw_server_SOURCES=
qw_server_LDADD= libqw_server.a libqw_common.a $(asm) $(qw_server_LIBS) $(NET_LIBS) $(DL_LIBS) $(CURSES_LIBS)
qw_server_LDADD= libqw_server.a libqw_common.a $(qw_server_LIBS) $(NET_LIBS) $(DL_LIBS) $(CURSES_LIBS)
qw_server_LDFLAGS= $(common_ldflags)
qw_server_DEPENDENCIES= libqw_common.a libqw_server.a $(asm) $(qw_server_LIBS)
qw_server_DEPENDENCIES= libqw_common.a libqw_server.a $(qw_server_LIBS)
qw_master_SOURCES= master.c
qw_master_LDADD= $(top_builddir)/libs/util/libQFutil.la $(NET_LIBS)
@ -118,7 +110,7 @@ qw_client_LIBS= \
$(top_builddir)/libs/util/libQFutil.la \
$(top_builddir)/libs/gib/libQFgib.la
client_LIBS= $(asm) $(qw_client_LIBS)
client_LIBS= $(qw_client_LIBS)
client_libs= libqw_client.a libqw_common.a
libqw_client_a_SOURCES= \

View file

@ -419,7 +419,6 @@ SV_LinkEdict (edict_t *ent, qboolean touch_triggers)
/* POINT TESTING IN HULLS */
#ifndef USE_INTEL_ASM
int
SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
{
@ -428,8 +427,8 @@ SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
mplane_t *plane;
while (num >= 0) {
if (num < hull->firstclipnode || num > hull->lastclipnode)
Sys_Error ("SV_HullPointContents: bad node number");
//if (num < hull->firstclipnode || num > hull->lastclipnode)
// Sys_Error ("SV_HullPointContents: bad node number");
node = hull->clipnodes + num;
plane = hull->planes + node->planenum;
@ -446,7 +445,6 @@ SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
return num;
}
#endif // !USE_INTEL_ASM
int
SV_PointContents (const vec3_t p)

View file

@ -1,150 +0,0 @@
/*
worlda.S
x86 assembly-language server testing stuff
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
#include "asm_i386.h"
//#include "quakeasm.h"
//include "d_ifacea.h"
#ifdef USE_INTEL_ASM
.data
Ltemp: .long 0
.text
//----------------------------------------------------------------------
// hull-point test
//----------------------------------------------------------------------
#define hull 4+8 // because only partially pushed
#define num 8+4 // because only partially pushed
#define p 12+12 // because only partially pushed
.align 4
.globl C(SV_HullPointContents)
C(SV_HullPointContents):
pushl %edi // preserve register variables
movl num(%esp),%eax
testl %eax,%eax
js Lhquickout
// float d;
// dclipnode_t *node;
// mplane_t *plane;
pushl %ebx
movl hull(%esp),%ebx
pushl %ebp
movl p(%esp),%edx
movl hu_clipnodes(%ebx),%edi
movl hu_planes(%ebx),%ebp
subl %ebx,%ebx
pushl %esi
// %ebx: 0
// %eax: num
// %edx: p
// %edi: hull->clipnodes
// %ebp: hull->planes
// while (num >= 0)
// {
Lhloop:
// node = hull->clipnodes + num;
// plane = hull->planes + node->planenum;
// !!! if the size of dclipnode_t changes, the scaling of %eax needs to be
// changed !!!
movl nd_planenum(%edi,%eax,8),%ecx
movl nd_children(%edi,%eax,8),%eax
movl %eax,%esi
rorl $16,%eax
leal (%ecx,%ecx,4),%ecx
// if (plane->type < 3)
// d = p[plane->type] - plane->dist;
movb pl_type(%ebp,%ecx,4),%bl
cmpb $3,%bl
jb Lnodot
// else
// d = DotProduct (plane->normal, p) - plane->dist;
flds pl_normal(%ebp,%ecx,4)
fmuls 0(%edx)
flds pl_normal+4(%ebp,%ecx,4)
fmuls 4(%edx)
flds pl_normal+8(%ebp,%ecx,4)
fmuls 8(%edx)
fxch %st(1)
faddp %st(0),%st(2)
faddp %st(0),%st(1)
fsubs pl_dist(%ebp,%ecx,4)
jmp Lsub
Lnodot:
flds pl_dist(%ebp,%ecx,4)
fsubrs (%edx,%ebx,4)
Lsub:
sarl $16,%eax
sarl $16,%esi
// if (d < 0)
// num = node->children[1];
// else
// num = node->children[0];
fstps Ltemp
movl Ltemp,%ecx
sarl $31,%ecx
andl %ecx,%esi
xorl $0xFFFFFFFF,%ecx
andl %ecx,%eax
orl %esi,%eax
jns Lhloop
// return num;
Lhdone:
popl %esi
popl %ebp
popl %ebx // restore register variables
Lhquickout:
popl %edi
ret
#endif // USE_INTEL_ASM