Skip to content

Commit

Permalink
Fix windows build, enable x64 asm from sound mixer upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform committed Nov 15, 2023
1 parent 8fd21d9 commit f55da33
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 5 deletions.
61 changes: 61 additions & 0 deletions src/asm/common_x64.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
; common x86_64 assembler code form MSVC

.code

; params : RCX - void *jmp_buf[10], RSP[0] = callee addr, RSP[8] - callee stack pointer
Q_setjmp_c PROC
; store RIP in jmp_buf[0]
mov rax, [rsp+0]
mov [rcx+ 0], rax
; store RSP in jmp_buf[1]
lea rax, [rsp+8]
mov [rcx+ 8], rax
; store all remaining regs
mov [rcx+16], rbp
mov [rcx+24], rbx
mov [rcx+32], rsi
mov [rcx+40], rdi
mov [rcx+48], r12
mov [rcx+56], r13
mov [rcx+64], r14
mov [rcx+72], r15
; set normal return code (0)
xor eax, eax
ret
Q_setjmp_c ENDP


; params : RCX - void *jmp_buf[10], RDX - return code
Q_longjmp_c PROC
; restore registers
mov r15, [rcx+72]
mov r14, [rcx+64]
mov r13, [rcx+56]
mov r12, [rcx+48]
mov rdi, [rcx+40]
mov rsi, [rcx+32]
mov rbx, [rcx+24]
mov rbp, [rcx+16]
mov rsp, [rcx+ 8]
; set return code in EAX
mov eax, edx
; jump to RIP
jmp qword ptr [rcx+ 0]
Q_longjmp_c ENDP


; input: RCX=eax, RDX=ecx, R8=out, R9=unused/scratch
CPUID_EX PROC
mov r9, rbx ; push rbx
mov eax, ecx
mov ecx, edx
cpuid
mov dword ptr [r8+0], eax
mov dword ptr [r8+4], ebx
mov dword ptr [r8+8], ecx
mov dword ptr [r8+12], edx
mov rbx, r9 ; pop rbx
ret
CPUID_EX ENDP

END
23 changes: 19 additions & 4 deletions src/win32/msvc2017/wolf.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;USE_CURL;CURL_STATICLIB;USE_OPENGL_API;ENABLE_SPLINES;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;USE_CURL;CURL_STATICLIB;USE_OPENGL_API;ENABLE_SPLINES;USE_WIN32_ASM;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
Expand Down Expand Up @@ -134,7 +134,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;USE_CURL;CURL_STATICLIB;USE_OPENGL_API;ENABLE_SPLINES;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;USE_CURL;CURL_STATICLIB;USE_OPENGL_API;ENABLE_SPLINES;USE_WIN32_ASM;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
Expand Down Expand Up @@ -172,7 +172,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;USE_CURL;USE_OPENGL_API;CURL_STATICLIB;ENABLE_SPLINES;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;USE_CURL;USE_OPENGL_API;CURL_STATICLIB;ENABLE_SPLINES;USE_WIN32_ASM;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
Expand Down Expand Up @@ -212,7 +212,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;USE_CURL;CURL_STATICLIB;USE_OPENGL_API;ENABLE_SPLINES;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_WARNINGS;USE_CURL;CURL_STATICLIB;USE_OPENGL_API;ENABLE_SPLINES;USE_WIN32_ASM;$(UseWASAPI);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
Expand Down Expand Up @@ -336,6 +336,8 @@
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Assembling...</Message>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ml64 /c /Zi /Fo"$(IntDir)%(Filename)%(Extension).obj" "%(FullPath)"</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Filename)%(Extension).obj;%(Outputs)</Outputs>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</CustomBuild>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -388,6 +390,19 @@
<ItemGroup>
<ResourceCompile Include="..\winquake.rc" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\asm\common_x64.asm">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ml64 /c /Zi /Fo"$(IntDir)%(Filename)%(Extension).obj" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Assembling...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Filename)%(Extension).obj;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ml64 /c /Zi /Fo"$(IntDir)%(Filename)%(Extension).obj" "%(FullPath)"</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Assembling...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)%(Filename)%(Extension).obj;%(Outputs)</Outputs>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/win32/msvc2017/wolf.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -344,5 +344,8 @@
<CustomBuild Include="..\..\asm\snd_mix_x64.asm">
<Filter>Source Files</Filter>
</CustomBuild>
<CustomBuild Include="..\..\asm\common_x64.asm">
<Filter>Source Files</Filter>
</CustomBuild>
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/win32/msvc2017/wolfded.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,19 @@
<ItemGroup>
<ResourceCompile Include="..\winquake.rc" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\asm\common_x64.asm">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">ml64 /c /Zi /Fo"$(IntDir)%(Filename)%(Extension).obj" "%(FullPath)"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">ml64 /c /Zi /Fo"$(IntDir)%(Filename)%(Extension).obj" "%(FullPath)"</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(IntDir)%(Filename)%(Extension).obj;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(IntDir)%(Filename)%(Extension).obj;%(Outputs)</Outputs>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Assembling...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Assembling...</Message>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/win32/msvc2017/wolfded.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,9 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\asm\common_x64.asm">
<Filter>Source Files</Filter>
</CustomBuild>
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/win32/win_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ If you have questions concerning this license or the applicable additional terms
===========================================================================
*/


#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#include "win_local.h"
Expand Down

0 comments on commit f55da33

Please sign in to comment.