Browse Source

First pass at making Quake engine code 64-bit ready. Not entirely stable yet, but it starts, runs and is partially playable. Will still crash when loading some levels.

console
Nico de Poel 5 years ago
parent
commit
9be3852e55
  1. 1
      .gitignore
  2. 30
      engine/code/cd_win.c
  3. 6
      engine/code/common.c
  4. 2
      engine/code/common.h
  5. 14
      engine/code/net_main.c
  6. 2
      engine/code/snd_fmod.h
  7. 2
      engine/code/snd_mem.c
  8. 2
      engine/code/sys.h
  9. 2
      engine/code/sys_win.c
  10. 22
      engine/projects/uniquake/uniquake.vcxproj

1
.gitignore

@ -9,3 +9,4 @@ Release/
*.csproj
Logs/
Build/
Build64/

30
engine/code/cd_win.c

@ -57,7 +57,7 @@ static void CDAudio_Eject(void)
{
DWORD dwReturn;
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD)NULL))
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, (DWORD_PTR)NULL))
Con_DPrintf("MCI_SET_DOOR_OPEN failed (%i)\n", dwReturn);
}
@ -66,7 +66,7 @@ static void CDAudio_CloseDoor(void)
{
DWORD dwReturn;
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD)NULL))
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_DOOR_CLOSED, (DWORD_PTR)NULL))
Con_DPrintf("MCI_SET_DOOR_CLOSED failed (%i)\n", dwReturn);
}
@ -80,7 +80,7 @@ static int CDAudio_GetAudioDiskInfo(void)
cdValid = false;
mciStatusParms.dwItem = MCI_STATUS_READY;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("CDAudio: drive ready test - get status failed\n");
@ -93,7 +93,7 @@ static int CDAudio_GetAudioDiskInfo(void)
}
mciStatusParms.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("CDAudio: get tracks - status failed\n");
@ -139,7 +139,7 @@ void CDAudio_Play(byte track, qboolean looping)
// don't try to play a non-audio track
mciStatusParms.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
mciStatusParms.dwTrack = track;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
@ -154,7 +154,7 @@ void CDAudio_Play(byte track, qboolean looping)
// get the length of the track to be played
mciStatusParms.dwItem = MCI_STATUS_LENGTH;
mciStatusParms.dwTrack = track;
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD) (LPVOID) &mciStatusParms);
dwReturn = mciSendCommand(wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT, (DWORD_PTR) (LPVOID) &mciStatusParms);
if (dwReturn)
{
Con_DPrintf("MCI_STATUS failed (%i)\n", dwReturn);
@ -175,8 +175,8 @@ void CDAudio_Play(byte track, qboolean looping)
end_pos = mciPlayParms.dwTo;
// jkrige - CD Resume
mciPlayParms.dwCallback = (DWORD)mainwindow;
dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID) &mciPlayParms);
mciPlayParms.dwCallback = (DWORD_PTR)mainwindow;
dwReturn = mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD_PTR)(LPVOID) &mciPlayParms);
if (dwReturn)
{
Con_DPrintf("CDAudio: MCI_PLAY failed (%i)\n", dwReturn);
@ -202,7 +202,7 @@ void CDAudio_Stop(void)
if (!playing)
return;
if (dwReturn = mciSendCommand(wDeviceID, MCI_STOP, 0, (DWORD)NULL))
if (dwReturn = mciSendCommand(wDeviceID, MCI_STOP, 0, (DWORD_PTR)NULL))
Con_DPrintf("MCI_STOP failed (%i)", dwReturn);
wasPlaying = false;
@ -221,8 +221,8 @@ void CDAudio_Pause(void)
if (!playing)
return;
mciGenericParms.dwCallback = (DWORD)mainwindow;
if (dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD)(LPVOID) &mciGenericParms))
mciGenericParms.dwCallback = (DWORD_PTR)mainwindow;
if (dwReturn = mciSendCommand(wDeviceID, MCI_PAUSE, 0, (DWORD_PTR)(LPVOID) &mciGenericParms))
Con_DPrintf("MCI_PAUSE failed (%i)", dwReturn);
wasPlaying = playing;
@ -525,7 +525,7 @@ int CDAudio_Init(void)
return -1;
mciOpenParms.lpstrDeviceType = "cdaudio";
if (dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (DWORD) (LPVOID) &mciOpenParms))
if (dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (DWORD_PTR) (LPVOID) &mciOpenParms))
{
Con_Printf("CDAudio_Init: MCI_OPEN failed (%i)\n", dwReturn);
return -1;
@ -534,10 +534,10 @@ int CDAudio_Init(void)
// Set the time format to track/minute/second/frame (TMSF).
mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD)(LPVOID) &mciSetParms))
if (dwReturn = mciSendCommand(wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)(LPVOID) &mciSetParms))
{
Con_Printf("MCI_SET_TIME_FORMAT failed (%i)\n", dwReturn);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, (DWORD)NULL);
mciSendCommand(wDeviceID, MCI_CLOSE, 0, (DWORD_PTR)NULL);
return -1;
}
@ -569,7 +569,7 @@ void CDAudio_Shutdown(void)
if (!initialized)
return;
CDAudio_Stop();
if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD)NULL))
if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)NULL))
Con_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n");
}

6
engine/code/common.c

@ -168,7 +168,7 @@ void Q_memset (void *dest, int fill, int count)
{
int i;
if ( (((long)dest | count) & 3) == 0)
if ( (((intptr_t)dest | count) & 3) == 0)
{
count >>= 2;
fill = fill | (fill<<8) | (fill<<16) | (fill<<24);
@ -184,7 +184,7 @@ void Q_memcpy (void *dest, void *src, int count)
{
int i;
if (( ( (long)dest | (long)src | count) & 3) == 0 )
if (( ( (intptr_t)dest | (intptr_t)src | count) & 3) == 0 )
{
count>>=2;
for (i=0 ; i<count ; i++)
@ -2019,7 +2019,7 @@ void COM_AddGameDirectory (char *dir)
// jkrige - pack naming convention
char dirstring[1024];
int handle;
intptr_t handle;
struct _finddata_t fileinfo;
// jkrige - pack naming convention

2
engine/code/common.h

@ -63,7 +63,7 @@ void InsertLinkAfter (link_t *l, link_t *after);
// (type *)STRUCT_FROM_LINK(link_t *link, type, member)
// ent = STRUCT_FROM_LINK(link,entity_t,order)
// FIXME: remove this mess!
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
#define STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (intptr_t)&(((t *)0)->m)))
//============================================================================

14
engine/code/net_main.c

@ -466,7 +466,7 @@ struct
{
double time;
int op;
long session;
intptr_t session;
} vcrConnect;
qsocket_t *NET_CheckNewConnections (void)
@ -488,7 +488,7 @@ qsocket_t *NET_CheckNewConnections (void)
{
vcrConnect.time = host_time;
vcrConnect.op = VCR_OP_CONNECT;
vcrConnect.session = (long)ret;
vcrConnect.session = (intptr_t)ret;
Sys_FileWrite (vcrFile, &vcrConnect, sizeof(vcrConnect));
Sys_FileWrite (vcrFile, ret->address, NET_NAMELEN);
}
@ -595,7 +595,7 @@ int NET_GetMessage (qsocket_t *sock)
{
vcrGetMessage.time = host_time;
vcrGetMessage.op = VCR_OP_GETMESSAGE;
vcrGetMessage.session = (long)sock;
vcrGetMessage.session = (intptr_t)sock;
vcrGetMessage.ret = ret;
vcrGetMessage.len = net_message.cursize;
Sys_FileWrite (vcrFile, &vcrGetMessage, 24);
@ -608,7 +608,7 @@ int NET_GetMessage (qsocket_t *sock)
{
vcrGetMessage.time = host_time;
vcrGetMessage.op = VCR_OP_GETMESSAGE;
vcrGetMessage.session = (long)sock;
vcrGetMessage.session = (intptr_t)sock;
vcrGetMessage.ret = ret;
Sys_FileWrite (vcrFile, &vcrGetMessage, 20);
}
@ -659,7 +659,7 @@ int NET_SendMessage (qsocket_t *sock, sizebuf_t *data)
{
vcrSendMessage.time = host_time;
vcrSendMessage.op = VCR_OP_SENDMESSAGE;
vcrSendMessage.session = (long)sock;
vcrSendMessage.session = (intptr_t)sock;
vcrSendMessage.r = r;
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
}
@ -690,7 +690,7 @@ int NET_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data)
{
vcrSendMessage.time = host_time;
vcrSendMessage.op = VCR_OP_SENDMESSAGE;
vcrSendMessage.session = (long)sock;
vcrSendMessage.session = (intptr_t)sock;
vcrSendMessage.r = r;
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
}
@ -725,7 +725,7 @@ qboolean NET_CanSendMessage (qsocket_t *sock)
{
vcrSendMessage.time = host_time;
vcrSendMessage.op = VCR_OP_CANSENDMESSAGE;
vcrSendMessage.session = (long)sock;
vcrSendMessage.session = (intptr_t)sock;
vcrSendMessage.r = r;
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
}

2
engine/code/snd_fmod.h

@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _SND_FMOD_H_
#define _SND_FMOD_H_
#define UQE_FMOD
#ifdef UQE_FMOD
#define UQE_FMOD_CDAUDIO

2
engine/code/snd_mem.c

@ -235,7 +235,7 @@ void DumpChunks(void)
memcpy (str, data_p, 4);
data_p += 4;
iff_chunk_len = GetLittleLong();
Con_Printf ("0x%x : %s (%d)\n", (int)(data_p - 4), str, iff_chunk_len);
Con_Printf ("0x%x : %s (%d)\n", (intptr_t)(data_p - 4), str, iff_chunk_len);
data_p += (iff_chunk_len + 1) & ~1;
} while (data_p < iff_end);
}

2
engine/code/sys.h

@ -53,7 +53,7 @@ void Sys_mkdir (char *path);
//
// memory protection
//
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
void Sys_MakeCodeWriteable (uintptr_t startaddr, size_t length);
//
// system IO

2
engine/code/sys_win.c

@ -364,7 +364,7 @@ SYSTEM IO
Sys_MakeCodeWriteable
================
*/
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length)
void Sys_MakeCodeWriteable (uintptr_t startaddr, size_t length)
{
DWORD flOldProtect;

22
engine/projects/uniquake/uniquake.vcxproj

@ -43,7 +43,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@ -75,7 +75,7 @@
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>UNIQUAKE</TargetName>
<TargetName>uniquake</TargetName>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -92,7 +92,7 @@
<WarningLevel>Level1</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;UNIQUAKE_EXPORTS;_WINDOWS;_USRDLL;GLQUAKE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;UNIQUAKE_EXPORTS;_WINDOWS;_USRDLL;GLQUAKE;UQE_FMOD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
@ -106,15 +106,18 @@
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;opengl32.lib;winmm.lib;wsock32.lib;glu32.lib;fmodexL_vc.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\fmod-4\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>copy $(TargetDir)$(TargetName).dll $(SolutionDir)..\..\..\Assets\Plugins\windows\x86\uniquake.dll</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level1</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;UNIQUAKE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;UNIQUAKE_EXPORTS;_WINDOWS;_USRDLL;GLQUAKE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>false</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
@ -123,9 +126,12 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>fmodexL_vc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;opengl32.lib;winmm.lib;wsock32.lib;glu32.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\fmod-4\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>copy $(TargetDir)$(TargetName).dll $(SolutionDir)..\..\..\Assets\Plugins\windows\x86_64\uniquake.dll</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>

Loading…
Cancel
Save