From f0fcd058da4dcc58ad938dd00e708c72798b2ff7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 19:28:55 -0400 Subject: [PATCH 1/2] Get rid of in-line assembly in idiv16(). This cannot work with MinGW -masm=intel, only -masm=att. --- Source/Glide64/DepthBufferRender.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/Source/Glide64/DepthBufferRender.cpp b/Source/Glide64/DepthBufferRender.cpp index ae4f367aa..29b7ee474 100644 --- a/Source/Glide64/DepthBufferRender.cpp +++ b/Source/Glide64/DepthBufferRender.cpp @@ -97,31 +97,7 @@ __inline int imul14(int x, int y) // (x * y) >> 14 __inline int idiv16(int x, int y) // (x << 16) / y { - //x = (((long long)x) << 16) / ((long long)y); - /* - eax = x; - ebx = y; - edx = x; - (x << 16) | () - */ -#if !defined(__GNUC__) && !defined(NO_ASM) - __asm { - mov eax, x - mov ebx, y - mov edx,eax - sar edx,16 - shl eax,16 - idiv ebx - mov x, eax - } -#elif !defined(NO_ASM) - int reminder; - asm ("idivl %[divisor]" - : "=a" (x), "=d" (reminder) - : [divisor] "g" (y), "d" (x >> 16), "a" (x << 16)); -#else - x = (((long long)x) << 16) / ((long long)y); -#endif + x = ((int64_t)x << 16) / (int64_t)y; return x; } From 102a8f650b39b67372d954c8bfa539d8a6badbb3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 19:30:33 -0400 Subject: [PATCH 2/2] Do not rely on dynamic-width `long long` type; use int64_t. --- Source/Glide64/DepthBufferRender.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Glide64/DepthBufferRender.cpp b/Source/Glide64/DepthBufferRender.cpp index 29b7ee474..2ed36e116 100644 --- a/Source/Glide64/DepthBufferRender.cpp +++ b/Source/Glide64/DepthBufferRender.cpp @@ -87,12 +87,12 @@ static int left_z, left_dzdy; __inline int imul16(int x, int y) // (x * y) >> 16 { - return (((long long)x) * ((long long)y)) >> 16; + return ((int64_t)x * (int64_t)y) >> 16; } __inline int imul14(int x, int y) // (x * y) >> 14 { - return (((long long)x) * ((long long)y)) >> 14; + return ((int64_t)x * (int64_t)y) >> 14; } __inline int idiv16(int x, int y) // (x << 16) / y