diff --git a/docs/rh-log.txt b/docs/rh-log.txt
index 34fa683bc..c2bc43831 100644
--- a/docs/rh-log.txt
+++ b/docs/rh-log.txt
@@ -1,3 +1,8 @@
+April 28, 2008
+- Various fixes for compiling working 64-bit binaries with Visual C++. The
+ number of changes was pleasantly small, and a cursory check seems to show
+ everything working alright.
+
April 27, 2008
- Separated the skin scale values into separate X and Y values so that skins
automatically generated for different player classes can use both the
diff --git a/jpeg-6b/jpeg-6b.vcproj b/jpeg-6b/jpeg-6b.vcproj
index f99a9999c..5b60647db 100644
--- a/jpeg-6b/jpeg-6b.vcproj
+++ b/jpeg-6b/jpeg-6b.vcproj
@@ -80,6 +80,69 @@
Name="VCPostBuildEventTool"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -114,7 +117,6 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
- CallingConvention="1"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp
index d8ae64a46..be0e8a6b6 100644
--- a/src/dobjtype.cpp
+++ b/src/dobjtype.cpp
@@ -43,8 +43,8 @@ TArray PClass::m_Types;
PClass *PClass::TypeHash[PClass::HASH_SIZE];
bool PClass::bShutdown;
-// A harmless non_NULL FlatPointer for classes without pointers.
-static const size_t TheEnd = ~0u;
+// A harmless non-NULL FlatPointer for classes without pointers.
+static const size_t TheEnd = ~(size_t)0;
static int STACK_ARGS cregcmp (const void *a, const void *b)
{
diff --git a/src/doomtype.h b/src/doomtype.h
index c3b9d8f39..6b9232261 100644
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -45,8 +45,10 @@
#if (!defined(_M_IX86) && !defined(__i386__)) || defined(__APPLE__)
// The assembly code requires an x86 processor.
// And needs to be tweaked for Mach-O before enabled on Macs.
+#ifndef NOASM
#define NOASM
#endif
+#endif
#ifndef NOASM
#ifndef USEASM
diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp
index 86d43a623..ffa69f705 100644
--- a/src/nodebuild_extract.cpp
+++ b/src/nodebuild_extract.cpp
@@ -71,7 +71,9 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
memcpy (outNodes, &Nodes[0], nodeCount*sizeof(node_t));
for (i = 0; i < nodeCount; ++i)
{
- for (int j = 0; j < 2; ++j)
+ // Go backwards because on 64-bit systems, both of the intchildren are
+ // inside the first in-game child.
+ for (int j = 1; j >= 0; --j)
{
if (outNodes[i].intchildren[j] & 0x80000000)
{
@@ -351,7 +353,7 @@ DWORD FNodeBuilder::PushGLSeg (TArray &segs, const FPrivSeg *seg, vertex_
newseg.sidedef = NULL;
}
newseg.PartnerSeg = (seg_t *)(seg->partner == DWORD_MAX ? 0 : (size_t)seg->partner + 1);
- newseg.bPolySeg = false;
+ newseg.bPolySeg = false;
newseg.Subsector = NULL;
return (DWORD)segs.Push (newseg);
}
@@ -367,7 +369,7 @@ void FNodeBuilder::PushConnectingGLSeg (int subsector, TArray &segs, vert
newseg.linedef = NULL;
newseg.sidedef = NULL;
newseg.PartnerSeg = NULL;
- newseg.bPolySeg = false;
+ newseg.bPolySeg = false;
newseg.Subsector = NULL;
segs.Push (newseg);
}
diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp
index f34b865a2..55ded1e13 100644
--- a/src/s_advsound.cpp
+++ b/src/s_advsound.cpp
@@ -299,7 +299,7 @@ void S_HashSounds ()
{
unsigned int i;
unsigned int j;
- size_t size;
+ unsigned int size;
S_sfx.ShrinkToFit ();
size = S_sfx.Size ();
diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp
index 041da2cb4..9709e0a56 100644
--- a/src/sound/fmodsound.cpp
+++ b/src/sound/fmodsound.cpp
@@ -1490,7 +1490,7 @@ void FMODSoundRenderer::LoadSound(sfxinfo_t *sfx)
{
if (sfx->data == NULL)
{
- DPrintf("loading sound \"%s\" (%d) ", sfx->name.GetChars(), sfx - &S_sfx[0]);
+ DPrintf("loading sound \"%s\" (%d)\n", sfx->name.GetChars(), sfx - &S_sfx[0]);
getsfx(sfx);
}
}
diff --git a/src/stats.h b/src/stats.h
index 07417339e..a02e5a124 100644
--- a/src/stats.h
+++ b/src/stats.h
@@ -41,7 +41,11 @@ extern "C" double CyclesPerSecond;
#if _MSC_VER
+#define _interlockedbittestandset64 hackfixfor
+#define _interlockedbittestandreset64 x64compilation
#include
+#undef _interlockedbittestandset64
+#undef _interlockedbittestandreset64
typedef QWORD cycle_t;
diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp
index 0d20e37bb..55bacea2f 100644
--- a/src/textures/multipatchtexture.cpp
+++ b/src/textures/multipatchtexture.cpp
@@ -411,7 +411,7 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota
for(int i=0;ibComplex || inf == NULL)
{
@@ -1018,7 +1018,8 @@ void FMultiPatchTexture::ParsePatch(FScanner &sc, TexPart & part)
static const char *styles[] = {"copy", "blend", "add", "subtract", "reversesubtract", "modulate", "copyalpha", NULL };
sc.MustGetString();
part.op = sc.MustMatchString(styles);
- bTranslucentPatches = bComplex = (part.op != OP_COPY);
+ bComplex = (part.op != OP_COPY);
+ bTranslucentPatches = bComplex;
}
}
}
diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp
index 4fae6a995..a92de0f02 100644
--- a/src/win32/fb_d3d9.cpp
+++ b/src/win32/fb_d3d9.cpp
@@ -46,6 +46,7 @@
#include
#include
+
#include
#define USE_WINDOWS_DWORD
@@ -66,8 +67,6 @@
#include "st_stuff.h"
#include "win32iface.h"
-#include
-
// MACROS ------------------------------------------------------------------
// The number of points for the vertex buffer.
diff --git a/src/win32/helperthread.cpp b/src/win32/helperthread.cpp
index 5d7521370..68494ac90 100644
--- a/src/win32/helperthread.cpp
+++ b/src/win32/helperthread.cpp
@@ -117,7 +117,7 @@ bool FHelperThread::LaunchThread ()
};
__try
{
- RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info );
+ RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR *)&info );
}
__except(EXCEPTION_CONTINUE_EXECUTION)
{
diff --git a/src/win32/i_cd.cpp b/src/win32/i_cd.cpp
index c1d5328be..b4982b865 100644
--- a/src/win32/i_cd.cpp
+++ b/src/win32/i_cd.cpp
@@ -782,7 +782,7 @@ LRESULT CALLBACK FCDThread::CD_WndProc (HWND hWnd, UINT message,
case MM_MCINOTIFY:
if (wParam == MCI_NOTIFY_SUCCESSFUL)
{
- FCDThread *self = (FCDThread *)(LONG_PTR)GetWindowLongPtr (hWnd, GWL_USERDATA);
+ FCDThread *self = (FCDThread *)(LONG_PTR)GetWindowLongPtr (hWnd, GWLP_USERDATA);
// Using SendMessage could deadlock, so don't do that.
self->Dispatch (self->Looping ? CDM_Replay : CDM_Stop);
}
diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp
index cec0295e1..16841194c 100644
--- a/src/win32/i_crash.cpp
+++ b/src/win32/i_crash.cpp
@@ -670,14 +670,29 @@ HANDLE WriteTextReport ()
if (ctxt->ContextFlags & CONTEXT_INTEGER)
{
+#ifndef _M_X64
Writef (file, "EAX=%08x EBX=%08x ECX=%08x EDX=%08x\r\nESI=%08x EDI=%08x\r\n",
ctxt->Eax, ctxt->Ebx, ctxt->Ecx, ctxt->Edx, ctxt->Esi, ctxt->Edi);
+#else
+ Writef (file, "RAX=%016I64x RBX=%016I64x RCX=%016I64x\r\n"
+ "RDX=%016I64x RSI=%016I64x RDI=%016I64x\r\n"
+ "RBP=%016I64x R8=%016I64x R9=%016I64x\r\n"
+ "R10=%016I64x R11=%016I64x R12=%016I64x\r\n"
+ "R13=%016I64x R14=%016I64x R15=%016I64x\r\n",
+ ctxt->Rax, ctxt->Rbx, ctxt->Rcx, ctxt->Rdx, ctxt->Rsi, ctxt->Rdi, ctxt->Rbp,
+ ctxt->R8, ctxt->R9, ctxt->R10, ctxt->R11, ctxt->R12, ctxt->R13, ctxt->R14, ctxt->R15);
+#endif
}
if (ctxt->ContextFlags & CONTEXT_CONTROL)
{
+#ifndef _M_X64
Writef (file, "EBP=%08x EIP=%08x ESP=%08x CS=%04x SS=%04x\r\nEFlags=%08x\r\n",
ctxt->Ebp, ctxt->Eip, ctxt->Esp, ctxt->SegCs, ctxt->SegSs, ctxt->EFlags);
+#else
+ Writef (file, "RIP=%016I64x RSP=%016I64x\r\nCS=%04x SS=%04x EFlags=%08x\r\n",
+ ctxt->Rip, ctxt->Rsp, ctxt->SegCs, ctxt->SegSs, ctxt->EFlags);
+#endif
DWORD j;
@@ -694,6 +709,7 @@ HANDLE WriteTextReport ()
if (ctxt->ContextFlags & CONTEXT_FLOATING_POINT)
{
+#ifndef _M_X64
Writef (file,
"\r\nFPU State:\r\n ControlWord=%04x StatusWord=%04x TagWord=%04x\r\n"
" ErrorOffset=%08x\r\n ErrorSelector=%08x\r\n DataOffset=%08x\r\n DataSelector=%08x\r\n"
@@ -707,6 +723,16 @@ HANDLE WriteTextReport ()
Writef (file, "MM%d=%08x%08x\r\n", i, *(DWORD *)(&ctxt->FloatSave.RegisterArea[20*i+4]),
*(DWORD *)(&ctxt->FloatSave.RegisterArea[20*i]));
}
+#else
+ for (i = 0; i < 8; ++i)
+ {
+ Writef (file, "MM%d=%016I64x\r\n", i, ctxt->Legacy[i].Low);
+ }
+ for (i = 0; i < 16; ++i)
+ {
+ Writef (file, "XMM%d=%016I64x%016I64x\r\n", i, ctxt->FltSave.XmmRegisters[i].High, ctxt->FltSave.XmmRegisters[i].Low);
+ }
+#endif
}
AddToolHelp (file);
@@ -716,8 +742,13 @@ HANDLE WriteTextReport ()
if (ctxt->ContextFlags & CONTEXT_CONTROL)
{
+#ifndef _M_X64
AddStackInfo (file, (void *)(size_t)CrashPointers.ContextRecord->Esp,
CrashPointers.ExceptionRecord->ExceptionCode);
+#else
+ AddStackInfo (file, (void *)CrashPointers.ContextRecord->Rsp,
+ CrashPointers.ExceptionRecord->ExceptionCode);
+#endif
}
return file;
@@ -904,16 +935,17 @@ static void StackWalk (HANDLE file, void *dumpaddress, DWORD *topOfStack, DWORD
DWORD_PTR codeEnd = codeStart + pHeader->SizeOfCode;
Writef (file, "\r\nPossible call trace:\r\n %08x BOOM", CrashAddress);
- for (DWORD_PTR *scan = addr; scan < topOfStack; ++scan)
+ for (DWORD *scan = addr; scan < topOfStack; ++scan)
{
- DWORD_PTR code;
-
if (scan == jump)
{
scan = topOfStack - 16384/4;
Writef (file, "\r\n\r\n . . . . Snip . . . .\r\n");
}
+#ifndef _M_X64
+ DWORD_PTR code;
+
if (SafeReadMemory (scan, &code, sizeof(code)) &&
code >= codeStart && code < codeEnd)
{
@@ -1070,6 +1102,7 @@ static void StackWalk (HANDLE file, void *dumpaddress, DWORD *topOfStack, DWORD
}
}
}
+#endif
}
Writef (file, "\r\n");
}
diff --git a/src/win32/i_input.cpp b/src/win32/i_input.cpp
index 53973dea5..f089c2689 100644
--- a/src/win32/i_input.cpp
+++ b/src/win32/i_input.cpp
@@ -1603,7 +1603,7 @@ static void CenterMouse_Win32 (LONG curx, LONG cury)
static void SetCursorState (int visible)
{
HCURSOR usingCursor = visible ? TheArrowCursor : TheInvisibleCursor;
- SetClassLongPtr (Window, GCL_HCURSOR, (LONG_PTR)usingCursor);
+ SetClassLongPtr (Window, GCLP_HCURSOR, (LONG_PTR)usingCursor);
if (HaveFocus)
{
SetCursor (usingCursor);
diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp
index b1ccaef8b..d97bf302a 100644
--- a/src/win32/i_main.cpp
+++ b/src/win32/i_main.cpp
@@ -83,7 +83,13 @@
// MACROS ------------------------------------------------------------------
// The main window's title.
-#define WINDOW_TITLE GAMESIG " " DOTVERSIONSTR " (" __DATE__ ")"
+#ifdef _M_X64
+#define X64 " 64-bit"
+#else
+#define X64 ""
+#endif
+
+#define WINDOW_TITLE GAMESIG " " DOTVERSIONSTR X64 " (" __DATE__ ")"
// The maximum number of functions that can be registered with atterm.
#define MAX_TERMS 32
@@ -1094,11 +1100,19 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info)
// Otherwise, put the crashing thread to sleep and signal the main thread to clean up.
if (GetCurrentThreadId() == MainThreadID)
{
+#ifndef _M_X64
info->ContextRecord->Eip = (DWORD_PTR)ExitFatally;
+#else
+ info->ContextRecord->Rip = (DWORD_PTR)ExitFatally;
+#endif
}
else
{
+#ifndef _M_X64
info->ContextRecord->Eip = (DWORD_PTR)SleepForever;
+#else
+ info->ContextRecord->Rip = (DWORD_PTR)ExitFatally;
+#endif
QueueUserAPC (ExitFatally, MainThread, 0);
}
return EXCEPTION_CONTINUE_EXECUTION;
diff --git a/src/win32/i_movie.cpp b/src/win32/i_movie.cpp
index 05045bbdd..171c8bc88 100644
--- a/src/win32/i_movie.cpp
+++ b/src/win32/i_movie.cpp
@@ -109,7 +109,8 @@ LRESULT CALLBACK MovieWndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
{
case WM_GRAPHNOTIFY:
{
- long code, parm1, parm2;
+ long code;
+ LONG_PTR parm1, parm2;
while (event->GetEvent (&code, &parm1, &parm2, 0) == S_OK)
{
diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp
index 2e8b333dd..7ba365ad6 100644
--- a/src/win32/i_system.cpp
+++ b/src/win32/i_system.cpp
@@ -179,7 +179,7 @@ int I_WaitForTicEvent (int prevtic)
return tics;
}
-void CALLBACK TimerTicked (UINT id, UINT msg, DWORD user, DWORD dw1, DWORD dw2)
+void CALLBACK TimerTicked (UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2)
{
tics++;
ted_start = timeGetTime ();
diff --git a/tools/lemon/lemon.vcproj b/tools/lemon/lemon.vcproj
index 137b9d7b0..48f53a715 100644
--- a/tools/lemon/lemon.vcproj
+++ b/tools/lemon/lemon.vcproj
@@ -220,7 +220,6 @@
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="0"
- CallingConvention="0"
CompileAs="1"
DisableSpecificWarnings="4996"
/>
diff --git a/tools/re2c/re2c.vcproj b/tools/re2c/re2c.vcproj
index dbaedb5f6..8bc118ea2 100644
--- a/tools/re2c/re2c.vcproj
+++ b/tools/re2c/re2c.vcproj
@@ -217,7 +217,6 @@
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
- CallingConvention="0"
DisableSpecificWarnings="4996"
/>
@@ -204,10 +202,9 @@
/>
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+