- moved winbits.cpp to the platform folder and cleaned out unused parts.

This commit is contained in:
Christoph Oelckers 2019-09-25 22:38:47 +02:00
parent ad4527c8be
commit cd920299d0
13 changed files with 36 additions and 294 deletions

View file

@ -539,7 +539,7 @@ endif()
set( PLAT_WIN32_SOURCES
audiolib/src/driver_directsound.cpp
glad/src/glad_wgl.c
build/src/winbits.cpp
platform/win32/winbits.cpp
duke3d/src/startwin.game.cpp
rr/src/startwin.game.cpp
@ -689,7 +689,6 @@ file( GLOB HEADER_FILES
# without being compiled.
set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES}
build/src/mingw_main.cpp
build/src/sdlkeytrans.cpp
duke3d/src/gamestructures.cpp
rr/src/gamestructures.cpp
@ -828,7 +827,6 @@ set (PCH_SOURCES
build/src/textfont.cpp
build/src/tiles.cpp
build/src/timer.cpp
build/src/vfs.cpp
build/src/voxmodel.cpp
duke3d/src/actors.cpp
@ -1024,6 +1022,7 @@ include_directories(
libsmackerdec/include
thirdparty/include
common/utility
platform
${CMAKE_BINARY_DIR}/libraries/gdtoa
${CMAKE_BINARY_DIR}/libraries/enet

View file

@ -72,7 +72,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef _WIN32
# include <shellapi.h>
# define UPDATEINTERVAL 604800 // 1w
# include "winbits.h"
# include "win32/winbits.h"
#else
# ifndef GEKKO
# include <sys/ioctl.h>
@ -1440,8 +1440,6 @@ int app_main(int argc, char const * const * argv)
margv = argv;
#ifdef _WIN32
backgroundidle = 0;
G_ExtPreInit(argc, argv);
#ifdef DEBUGGINGAIDS

View file

@ -35,7 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef _WIN32
# define NEED_SHLWAPI_H
# include "windows_inc.h"
# include "winbits.h"
# include "win32/winbits.h"
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
# endif

View file

@ -1,23 +0,0 @@
// Windows layer-independent code
#include "compat.h"
#ifdef APPNAME
# define WindowClass APPNAME
#else
# define WindowClass "buildapp"
#endif
extern int32_t backgroundidle; // set to 1 to tell winlayer to go to idle priority when inactive
extern int64_t win_timerfreq;
extern char silentvideomodeswitch;
extern void win_init(void);
extern void win_setvideomode(int32_t c);
extern void win_uninit(void);
extern int32_t addsearchpath_ProgramFiles(const char *p);
extern int32_t win_buildargs(char **argvbuf);

View file

@ -1,97 +0,0 @@
/**
* @file main.c
* Copyright 2012, 2013 MinGW.org project
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* Extra startup code for applications which do not have a main function
* of their own (but do have a WinMain). Generally these are GUI
* applications, but they don't *have* to be.
*/
// Taken from mingwrt-4.0.0 src/libcrt/crt/main.c.
#include "compat.h"
#define ISSPACE(a) (a == ' ' || a == '\t')
extern int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
LPSTR szCmdLine, int nShow);
int
main (int argc ATTRIBUTE((unused)), char *argv[] ATTRIBUTE((unused)), char **environment ATTRIBUTE((unused)))
{
char *szCmd;
STARTUPINFO startinfo;
int nRet;
/* Get the command line passed to the process. */
szCmd = GetCommandLineA ();
GetStartupInfoA (&startinfo);
/* Strip off the name of the application and any leading
* whitespace. */
if (szCmd)
{
while (ISSPACE (*szCmd))
{
szCmd++;
}
/* On my system I always get the app name enclosed
* in quotes... */
if (*szCmd == '\"')
{
do
{
szCmd++;
}
while (*szCmd != '\"' && *szCmd != '\0');
if (*szCmd == '\"')
{
szCmd++;
}
}
else
{
/* If no quotes then assume first token is program
* name. */
while (!ISSPACE (*szCmd) && *szCmd != '\0')
{
szCmd++;
}
}
while (ISSPACE (*szCmd))
{
szCmd++;
}
}
nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd,
(startinfo.dwFlags & STARTF_USESHOWWINDOW) ?
startinfo.wShowWindow : SW_SHOWDEFAULT);
return nRet;
}

View file

@ -34,7 +34,7 @@
# include <mach/mach.h>
# include <mach/mach_time.h>
#elif defined _WIN32
# include "winbits.h"
# include "win32/winbits.h"
#endif
#include "vfs.h"
@ -445,7 +445,7 @@ int main(int argc, char *argv[])
#ifdef _WIN32
char* argvbuf;
int32_t buildargc = win_buildargs(&argvbuf);
int32_t buildargc = win_buildargs(&argvbuf);
const char** buildargv = (const char**)Xmalloc(sizeof(char*) * (buildargc + 1));
char* wp = argvbuf;
@ -691,10 +691,6 @@ void uninitsystem(void)
SDL_Quit();
#ifdef _WIN32
win_uninit();
#endif
#ifdef USE_OPENGL
# if SDL_MAJOR_VERSION!=1
SDL_GL_UnloadLibrary();
@ -2261,10 +2257,6 @@ int32_t handleevents_pollsdl(void)
appactive = (ev.window.event == SDL_WINDOWEVENT_FOCUS_GAINED);
if (g_mouseGrabbed && g_mouseEnabled)
grabmouse_low(appactive);
#ifdef _WIN32
if (backgroundidle)
SetPriorityClass(GetCurrentProcess(), appactive ? NORMAL_PRIORITY_CLASS : IDLE_PRIORITY_CLASS);
#endif
break;
case SDL_WINDOWEVENT_MOVED:

View file

@ -1,29 +0,0 @@
#include "vfs.h"
#include "cache1d.h"
#ifdef USE_PHYSFS
int32_t numgroupfiles;
void uninitgroupfile(void)
{
PHYSFS_deinit();
}
#include <sys/stat.h>
int32_t klseek(buildvfs_kfd handle, int32_t offset, int32_t whence)
{
// TODO: replace klseek calls with _{abs,cur,end} versions
if (whence == SEEK_CUR)
offset += PHYSFS_tell(handle);
else if (whence == SEEK_END)
offset += PHYSFS_fileLength(handle);
PHYSFS_seek(handle, offset);
return PHYSFS_tell(handle);
}
#endif

View file

@ -16,7 +16,7 @@
#ifdef _WIN32
# define NEED_SHLWAPI_H
# include "windows_inc.h"
# include "winbits.h"
# include "win32/winbits.h"
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
# endif

View file

@ -60,7 +60,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef _WIN32
# include <shellapi.h>
# define UPDATEINTERVAL 604800 // 1w
# include "winbits.h"
# include "win32/winbits.h"
#else
# ifndef GEKKO
# include <sys/ioctl.h>
@ -6370,8 +6370,6 @@ int app_main(int argc, char const * const * argv)
#ifdef _WIN32
backgroundidle = 0;
#ifndef USE_PHYSFS
#ifdef DEBUGGINGAIDS
extern int32_t (*check_filename_casing_fn)(void);

View file

@ -5,54 +5,26 @@
#include "baselayer.h"
#include "osd.h"
#include "cache1d.h"
#include "zstring.h"
#include "winbits.h"
int32_t backgroundidle = 1;
char silentvideomodeswitch = 0;
static char taskswitching = 1;
static OSVERSIONINFOEXA osv;
static int32_t togglecomp = 0;
FARPROC pwinever;
//
// CheckWinVersion() -- check to see what version of Windows we happen to be running under
// CheckWinVersion() -- check to see what version of Windows we happen to be running under (stripped down to what is actually still supported.)
//
static void win_printversion(void)
void win_init(void)
{
const char *ver = "";
OSVERSIONINFOEXA osv;
osv.dwOSVersionInfoSize = sizeof(osv);
GetVersionExA((LPOSVERSIONINFOA)&osv);
switch (osv.dwPlatformId)
{
case VER_PLATFORM_WIN32_WINDOWS:
if (osv.dwMinorVersion < 10)
ver = "95";
else if (osv.dwMinorVersion < 90)
ver = "98";
else
ver = "ME";
break;
case VER_PLATFORM_WIN32_NT:
switch (osv.dwMajorVersion)
{
case 5:
switch (osv.dwMinorVersion)
{
case 0: ver = "2000"; break;
case 1: ver = "XP"; break;
case 2: ver = osv.wProductType == VER_NT_WORKSTATION ? "XP x64" : "Server 2003"; break;
}
break;
case 6:
switch (osv.dwMinorVersion)
{
@ -73,101 +45,33 @@ static void win_printversion(void)
break;
}
char *str = (char *)Xcalloc(1, 256);
int l;
if (pwinever)
l = Bsprintf(str, "Wine %s, identifying as Windows %s", (char *)pwinever(), ver);
else
l = Bsprintf(str, "Windows %s", ver);
FStringf str("Windows %s", ver);
// service packs
if (osv.szCSDVersion[0])
{
str[l] = 32;
Bstrcat(&str[l], osv.szCSDVersion);
str.AppendFormat(" %s", osv.szCSDVersion);
}
initprintf("Running on %s (build %lu.%lu.%lu)\n", str, osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber);
Xfree(str);
initprintf("Running on %s (build %lu.%lu.%lu)\n", str.GetChars(), osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber);
}
static void ToggleDesktopComposition(BOOL compEnable)
{
static HMODULE hDWMApiDLL = NULL;
static HRESULT(WINAPI *aDwmEnableComposition)(UINT);
if (!hDWMApiDLL && (hDWMApiDLL = LoadLibraryA("DWMAPI.DLL")))
aDwmEnableComposition = (HRESULT(WINAPI *)(UINT))(void (*)(void))GetProcAddress(hDWMApiDLL, "DwmEnableComposition");
if (aDwmEnableComposition)
{
aDwmEnableComposition(compEnable);
if (!silentvideomodeswitch)
initprintf("%sabling desktop composition...\n", (compEnable) ? "En" : "Dis");
}
}
typedef void (*dllSetString)(const char*);
void win_init(void)
{
uint32_t i;
static osdcvardata_t cvars_win[] =
{
{ "r_togglecomposition","enable/disable toggle of desktop composition when initializing screen modes",(void *) &togglecomp, CVAR_BOOL, 0, 1 },
};
for (i=0; i<ARRAY_SIZE(cvars_win); i++)
OSD_RegisterCvar(&cvars_win[i], osdcmd_cvar_set);
win_printversion();
}
void win_setvideomode(int32_t c)
{
if (togglecomp && osv.dwMajorVersion == 6 && osv.dwMinorVersion < 2)
ToggleDesktopComposition(c < 16);
}
void win_uninit(void)
{
}
//==========================================================================
//
// Miscellaneous
// win_buildargs
//
// This should be removed once everything can use the FArgs list.
//
//==========================================================================
int32_t addsearchpath_ProgramFiles(const char *p)
{
int32_t returncode = -1, i;
const char *ProgramFiles[2] = { Bgetenv("ProgramFiles"), Bgetenv("ProgramFiles(x86)") };
for (i = 0; i < 2; ++i)
{
if (ProgramFiles[i])
{
char *buffer = (char*)Xmalloc((strlen(ProgramFiles[i])+1+strlen(p)+1)*sizeof(char));
Bsprintf(buffer,"%s/%s",ProgramFiles[i],p);
if (addsearchpath(buffer) == 0) // if any work, return success
returncode = 0;
Xfree(buffer);
}
}
return returncode;
}
int32_t win_buildargs(char **argvbuf)
{
int32_t buildargc = 0;
FString cmdline_utf8 = FString(GetCommandLineW());
*argvbuf = Xstrdup(GetCommandLineA());
*argvbuf = Xstrdup(cmdline_utf8.GetChars());
if (*argvbuf)
{
@ -298,9 +202,3 @@ public:
static Initer initer;
// Workaround for a bug in mingwrt-4.0.0 and up where a function named main() in misc/src/libcrt/gdtoa/qnan.c takes precedence over the proper one in src/libcrt/crt/main.c.
#if (defined __MINGW32__ && EDUKE32_GCC_PREREQ(4,8)) || EDUKE32_CLANG_PREREQ(3,4)
# undef main
# include "mingw_main.cpp"
#endif

View file

@ -0,0 +1,8 @@
// Windows layer-independent code
#include "compat.h"
# define WindowClass "Demolition"
extern void win_init(void);
extern int32_t win_buildargs(char **argvbuf);

View file

@ -13,7 +13,7 @@
#ifdef _WIN32
# define NEED_SHLWAPI_H
# include "windows_inc.h"
# include "winbits.h"
# include "win32/winbits.h"
# ifndef KEY_WOW64_64KEY
# define KEY_WOW64_64KEY 0x0100
# endif

View file

@ -59,7 +59,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef _WIN32
# include <shellapi.h>
# define UPDATEINTERVAL 604800 // 1w
# include "winbits.h"
# include "win32/winbits.h"
#else
# ifndef GEKKO
# include <sys/ioctl.h>
@ -7751,8 +7751,6 @@ int app_main(int argc, char const * const * argv)
#ifdef _WIN32
backgroundidle = 0;
#ifdef DEBUGGINGAIDS
extern int32_t (*check_filename_casing_fn)(void);
check_filename_casing_fn = check_filename_casing;