client: Remove i386 GNU assembler version of S_WriteLinearBlastStereo16()

This was the last remaining GNU assembler code that was in its own
independent source file, as opposed to being embedded in C code with
GNU `__asm__ volatile` or MSVC `__asm` (which tends to be much easier
to deal with in a modern build system).

When the Quake 3 engine was originally written, this might have been
an "expensive" function when written in portable C, but after 25 years
of CPU development it's less likely to matter (and modern compilers
might produce faster results from the C code anyway).

Resolves: https://github.com/ioquake/ioq3/issues/778
Signed-off-by: Simon McVittie <smcv@debian.org>
This commit is contained in:
Simon McVittie 2025-08-23 10:54:32 +01:00 committed by Tim Angus
parent 9f0280bca1
commit dc00968bc1
7 changed files with 3 additions and 163 deletions

View File

@ -2172,7 +2172,6 @@ endif
ifeq ($(ARCH),x86)
Q3OBJ += \
$(B)/client/snd_mixa.o \
$(B)/client/snapvector.o \
$(B)/client/ftola.o
endif

View File

@ -11,10 +11,6 @@ set(ASM_SOURCES
${SOURCE_DIR}/asm/snapvector.c
)
set(CLIENT_ASM_SOURCES
${SOURCE_DIR}/asm/snd_mixa.S
)
add_compile_options(-Wall -Wimplicit
-Wstrict-prototypes -Wformat=2 -Wformat-security
-Wstrict-aliasing=2 -Wmissing-format-attribute

View File

@ -1,37 +0,0 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
#ifndef __ASM_I386__
#define __ASM_I386__
#include "../qcommon/q_platform.h"
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif
#if defined(__ELF__) || defined(__WIN64__)
#define C(label) label
#else
#define C(label) _##label
#endif
#endif

View File

@ -1,106 +0,0 @@
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
This file is part of Quake III Arena source code.
Quake III Arena source code 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.
Quake III Arena source code 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 Quake III Arena source code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
//
// snd_mixa.s
// x86 assembly-language sound code
//
#include "qasm.h"
#if id386
.text
//----------------------------------------------------------------------
// Transfer of stereo buffer to 16-bit DMA buffer code
//----------------------------------------------------------------------
.globl C(S_WriteLinearBlastStereo16)
C(S_WriteLinearBlastStereo16):
pushl %edi
pushl %ebx
// int i;
// int val;
movl C(snd_linear_count),%ecx
movl C(snd_p),%ebx
movl C(snd_out),%edi
// for (i=0 ; i<snd_linear_count ; i+=2)
// {
LWLBLoopTop:
// val = (snd_p[i]*snd_vol)>>8;
// if (val > 0x7fff)
// snd_out[i] = 0x7fff;
// else if (val < (short)0x8000)
// snd_out[i] = (short)0x8000;
// else
// snd_out[i] = val;
movl -8(%ebx,%ecx,4),%eax
sarl $8,%eax
cmpl $0x7FFF,%eax
jg LClampHigh
cmpl $0xFFFF8000,%eax
jnl LClampDone
movl $0xFFFF8000,%eax
jmp LClampDone
LClampHigh:
movl $0x7FFF,%eax
LClampDone:
// val = (snd_p[i+1]*snd_vol)>>8;
// if (val > 0x7fff)
// snd_out[i+1] = 0x7fff;
// else if (val < (short)0x8000)
// snd_out[i+1] = (short)0x8000;
// else
// snd_out[i+1] = val;
movl -4(%ebx,%ecx,4),%edx
sarl $8,%edx
cmpl $0x7FFF,%edx
jg LClampHigh2
cmpl $0xFFFF8000,%edx
jnl LClampDone2
movl $0xFFFF8000,%edx
jmp LClampDone2
LClampHigh2:
movl $0x7FFF,%edx
LClampDone2:
shll $16,%edx
andl $0xFFFF,%eax
orl %eax,%edx
movl %edx,-4(%edi,%ecx,2)
// }
subl $2,%ecx
jnz LWLBLoopTop
// snd_p += snd_linear_count;
popl %ebx
popl %edi
ret
#endif // id386

View File

@ -31,7 +31,7 @@ int* snd_p;
int snd_linear_count;
short* snd_out;
#if !id386 // if configured not to use asm
#if defined(__GNUC__) || !id386
void S_WriteLinearBlastStereo16 (void)
{
@ -57,10 +57,8 @@ void S_WriteLinearBlastStereo16 (void)
snd_out[i+1] = val;
}
}
#elif defined(__GNUC__)
// uses snd_mixa.s
void S_WriteLinearBlastStereo16 (void);
#else
#else // MSVC on i386
__declspec( naked ) void S_WriteLinearBlastStereo16 (void)
{

View File

@ -69,8 +69,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#endif
#ifndef __ASM_I386__ // don't include the C bits if included from qasm.h
// for windows fastcall option
#define QDECL
#define QCALL
@ -419,5 +417,3 @@ float FloatSwap (const float *f);
#endif
#endif
#endif

View File

@ -51,7 +51,6 @@
2735379E14D8F13E000D6E73 /* botlib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2735379B14D8F13E000D6E73 /* botlib.a */; };
274FAB79178FA81800B17C7A /* snd_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 274FAB78178FA81700B17C7A /* snd_main.c */; };
274FAB7B178FA86E00B17C7A /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 274FAB7A178FA86E00B17C7A /* md5.c */; };
274FAB88178FA98E00B17C7A /* snd_mixa.s in Sources */ = {isa = PBXBuildFile; fileRef = 274FAB82178FA97100B17C7A /* snd_mixa.s */; };
274FABFD178FAC4900B17C7A /* vm_x86.c in Sources */ = {isa = PBXBuildFile; fileRef = 2711BE9E14D136DF005EB142 /* vm_x86.c */; };
274FABFE178FAC6E00B17C7A /* tr_noise.c in Sources */ = {isa = PBXBuildFile; fileRef = 27AAD064178E03620093DFC0 /* tr_noise.c */; };
2758BB3317905B8F007F6582 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2758BB3217905B8F007F6582 /* IOKit.framework */; };
@ -173,9 +172,7 @@
274FAB7A178FA86E00B17C7A /* md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = md5.c; sourceTree = "<group>"; };
274FAB7D178FA97100B17C7A /* ftola.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ftola.c; sourceTree = "<group>"; };
274FAB7F178FA97100B17C7A /* qasm-inline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "qasm-inline.h"; sourceTree = "<group>"; };
274FAB80178FA97100B17C7A /* qasm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = qasm.h; sourceTree = "<group>"; };
274FAB81178FA97100B17C7A /* snapvector.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = snapvector.c; sourceTree = "<group>"; };
274FAB82178FA97100B17C7A /* snd_mixa.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = snd_mixa.s; sourceTree = "<group>"; };
274FAB83178FA97100B17C7A /* ftola.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; path = ftola.asm; sourceTree = "<group>"; };
274FAB84178FA97100B17C7A /* snapvector.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; path = snapvector.asm; sourceTree = "<group>"; };
274FAB85178FA97100B17C7A /* vm_x86_64.asm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm.asm; path = vm_x86_64.asm; sourceTree = "<group>"; };
@ -596,9 +593,7 @@
children = (
274FAB7D178FA97100B17C7A /* ftola.c */,
274FAB7F178FA97100B17C7A /* qasm-inline.h */,
274FAB80178FA97100B17C7A /* qasm.h */,
274FAB81178FA97100B17C7A /* snapvector.c */,
274FAB82178FA97100B17C7A /* snd_mixa.s */,
274FAB83178FA97100B17C7A /* ftola.asm */,
274FAB84178FA97100B17C7A /* snapvector.asm */,
274FAB85178FA97100B17C7A /* vm_x86_64.asm */,
@ -921,7 +916,6 @@
27AAD02D178E013E0093DFC0 /* sdl_snd.c in Sources */,
274FAB79178FA81800B17C7A /* snd_main.c in Sources */,
274FAB7B178FA86E00B17C7A /* md5.c in Sources */,
274FAB88178FA98E00B17C7A /* snd_mixa.s in Sources */,
274FABFD178FAC4900B17C7A /* vm_x86.c in Sources */,
274FABFE178FAC6E00B17C7A /* tr_noise.c in Sources */,
A1F318612603128500A11B0E /* snapvector.c in Sources */,