From bac407c543f0c48716d140068359bad85bbe9988 Mon Sep 17 00:00:00 2001
From: Randy Heit <rheit@zdoom.fake>
Date: Fri, 2 Feb 2007 23:41:51 +0000
Subject: [PATCH] - Fixed: The SafeDivScales used a signed shift for their if
 test. This fails   when a == 0x80000000, because the result of abs will still
 be negative as   long as we use signed math. - Fixed: SafeDivScale31
 performed DivScale32 instead. - Fixed: R_DrawSpanP_ASM had a short jump into
 a different section.

SVN r472 (trunk)
---
 docs/rh-log.txt |  7 +++++++
 src/m_fixed.h   |  8 ++++----
 src/tmap.nas    |  2 +-
 zdoom.vcproj    | 12 ++++++------
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/docs/rh-log.txt b/docs/rh-log.txt
index c96a50fc3..e586dc0b4 100644
--- a/docs/rh-log.txt
+++ b/docs/rh-log.txt
@@ -1,3 +1,10 @@
+February 2, 2007
+- Fixed: The SafeDivScales used a signed shift for their if test. This fails
+  when a == 0x80000000, because the result of abs will still be negative as
+  long as we use signed math.
+- Fixed: SafeDivScale31 performed DivScale32 instead.
+- Fixed: R_DrawSpanP_ASM had a short jump into a different section.
+
 January 30, 2007
 - Fixed: When quiting from fullscreen mode, RestoreConView() did not ungrab
   the mouse.
diff --git a/src/m_fixed.h b/src/m_fixed.h
index 20daa5436..3d7f577b7 100644
--- a/src/m_fixed.h
+++ b/src/m_fixed.h
@@ -23,7 +23,7 @@
 #define MAKESAFEDIVSCALE(x) \
 	inline SDWORD SafeDivScale##x (SDWORD a, SDWORD b) \
 	{ \
-		if (abs(a) >> (31-x) >= abs (b)) \
+		if ((DWORD)abs(a) >> (31-x) >= (DWORD)abs (b)) \
 			return (a^b)<0 ? FIXED_MIN : FIXED_MAX; \
 		return DivScale##x (a, b); \
 	}
@@ -62,14 +62,14 @@ MAKESAFEDIVSCALE(30)
 
 inline SDWORD SafeDivScale31 (SDWORD a, SDWORD b)
 {
-	if (abs(a) >= abs (b))
+	if ((DWORD)abs(a) >= (DWORD)abs (b))
 		return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
-	return DivScale32 (a, b);
+	return DivScale31 (a, b);
 }
 
 inline SDWORD SafeDivScale32 (SDWORD a, SDWORD b)
 {
-	if (abs(a) >= abs (b) >> 1)
+	if ((DWORD)abs(a) >= (DWORD)abs (b) >> 1)
 		return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
 	return DivScale32 (a, b);
 }
diff --git a/src/tmap.nas b/src/tmap.nas
index 4a09d5b89..4ce36154a 100644
--- a/src/tmap.nas
+++ b/src/tmap.nas
@@ -321,7 +321,7 @@ R_DrawSpanP_ASM:
 	mov	eax,[ds_x2]
 	 mov	ecx,[ds_x1]
 	sub	eax,ecx
-	 jl	aret		; count < 0: nothing to do, so leave
+	 jl	near rdspret		; count < 0: nothing to do, so leave
 
 	push	ebx
 	push	edi
diff --git a/zdoom.vcproj b/zdoom.vcproj
index 4c2984919..6ee4c8b90 100644
--- a/zdoom.vcproj
+++ b/zdoom.vcproj
@@ -4774,7 +4774,7 @@
 					<Tool
 						Name="VCCustomBuildTool"
 						Description="Assembling $(InputPath)..."
-						CommandLine="nasmw -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						CommandLine="nasmw -g -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
 						Outputs="$(IntDir)/$(InputName).obj"
 					/>
 				</FileConfiguration>
@@ -4818,7 +4818,7 @@
 					<Tool
 						Name="VCCustomBuildTool"
 						Description="Assembling $(InputPath)..."
-						CommandLine="nasmw -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						CommandLine="nasmw -g -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
 						Outputs="$(IntDir)/$(InputName).obj"
 					/>
 				</FileConfiguration>
@@ -4862,7 +4862,7 @@
 					<Tool
 						Name="VCCustomBuildTool"
 						Description="Assembling $(InputPath)..."
-						CommandLine="nasmw -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						CommandLine="nasmw -g -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
@@ -4906,7 +4906,7 @@
 					<Tool
 						Name="VCCustomBuildTool"
 						Description="Assembling $(InputPath)..."
-						CommandLine="nasmw -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						CommandLine="nasmw -g -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
@@ -4950,7 +4950,7 @@
 					<Tool
 						Name="VCCustomBuildTool"
 						Description="Assembling $(InputPath)..."
-						CommandLine="nasmw -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						CommandLine="nasmw -g -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>
@@ -5376,7 +5376,7 @@
 					<Tool
 						Name="VCCustomBuildTool"
 						Description="Assembling $(InputPath)..."
-						CommandLine="nasmw -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+						CommandLine="nasmw -g -o &quot;$(IntDir)\$(InputName).obj&quot; -d OBJ_FORMAT_win32 -f win32 &quot;$(InputPath)&quot;&#x0D;&#x0A;"
 						Outputs="$(IntDir)\$(InputName).obj"
 					/>
 				</FileConfiguration>