Incinerated WinCE

This commit is contained in:
Monster Iestyn 2017-09-29 23:25:34 +01:00
parent be13f10626
commit 302d0425e0
55 changed files with 52 additions and 11269 deletions

View file

@ -210,7 +210,6 @@ endif
#indicate platform and what interface use with
ifndef WINCE
ifndef LINUX
ifndef FREEBSD
ifndef CYGWIN32
@ -224,7 +223,6 @@ endif
endif
endif
endif
endif
#determine the interface directory (where you put all i_*.c)
i_cdmus_o=$(OBJDIR)/i_cdmus.o
@ -317,16 +315,6 @@ ifdef MINGW
NASMFORMAT=win32
OBJDIR:=$(OBJDIR)/Mingw
BIN:=$(BIN)/Mingw
else
ifdef WINCE
INTERFACE=sdl12
NONX86=1
PREFIX?=arm-wince-pe
SDL=1
SDL12=1
OBJDIR:=$(OBJDIR)/WinCE
BIN:=$(BIN)/WinCE
endif
endif
endif
endif

View file

@ -10,9 +10,7 @@
/// \file d_clisrv.c
/// \brief SRB2 Network game communication and protocol, all OS independent parts.
#if !defined (UNDER_CE)
#include <time.h>
#endif
#ifdef __GNUC__
#include <unistd.h> //for unlink
#endif

View file

@ -30,14 +30,12 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap);
#endif
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
#include <direct.h>
#include <malloc.h>
#endif
#if !defined (UNDER_CE)
#include <time.h>
#endif
#include "doomdef.h"
#include "am_map.h"
@ -800,11 +798,9 @@ static void IdentifyVersion(void)
}
else
{
#ifndef _WIN32_WCE
if (getcwd(srb2path, 256) != NULL)
srb2waddir = srb2path;
else
#endif
{
srb2waddir = ".";
}
@ -953,7 +949,7 @@ void D_SRB2Main(void)
boolean autostart = false;
// keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
#if !defined (PC_DOS) && !defined(NOTERMIOS)
if (setvbuf(stderr, NULL, _IOFBF, 1000))
I_OutputMsg("setvbuf didnt work\n");
#endif
@ -975,11 +971,11 @@ void D_SRB2Main(void)
// identify the main IWAD file to use
IdentifyVersion();
#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
#if !defined(NOTERMIOS)
setbuf(stdout, NULL); // non-buffered output
#endif
#if defined (_WIN32_WCE) //|| defined (_DEBUG)
#if 0 //defined (_DEBUG)
devparm = M_CheckParm("-nodebug") == 0;
#else
devparm = M_CheckParm("-debug") != 0;
@ -1007,11 +1003,6 @@ void D_SRB2Main(void)
{
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)
I_Error("Please set $HOME to your home directory\n");
#elif defined (_WIN32_WCE) && 0
if (dedicated)
snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
else
snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
if (dedicated)
snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
@ -1419,14 +1410,14 @@ const char *D_Home(void)
userhome = M_GetNextParm();
else
{
#if !((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__APPLE__) && !defined(_WIN32_WCE)
#if !((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__APPLE__)
if (FIL_FileOK(CONFIGFILENAME))
usehome = false; // Let's NOT use home
else
#endif
userhome = I_GetEnv("HOME"); //Alam: my new HOME for srb2
}
#if defined (_WIN32) && !defined(_WIN32_WCE) //Alam: only Win32 have APPDATA and USERPROFILE
#ifdef _WIN32 //Alam: only Win32 have APPDATA and USERPROFILE
if (!userhome && usehome) //Alam: Still not?
{
char *testhome = NULL;

View file

@ -11,21 +11,17 @@
/// \brief Transfer a file using HSendPacket.
#include <stdio.h>
#ifndef _WIN32_WCE
#ifdef __OS2__
#include <sys/types.h>
#endif // __OS2__
#include <sys/stat.h>
#endif
#if !defined (UNDER_CE)
#include <time.h>
#endif
#if ((defined (_WIN32) && !defined (_WIN32_WCE)) || defined (__DJGPP__))
#if defined (_WIN32) || defined (__DJGPP__)
#include <io.h>
#include <direct.h>
#elif !defined (_WIN32_WCE)
#else
#include <sys/types.h>
#include <dirent.h>
#include <utime.h>
@ -34,7 +30,7 @@
#ifdef __GNUC__
#include <unistd.h>
#include <limits.h>
#elif defined (_WIN32) && !defined (_WIN32_WCE)
#elif defined (_WIN32)
#include <sys/utime.h>
#endif
#ifdef __DJGPP__

View file

@ -28,13 +28,11 @@
// Use Mixer interface?
#ifdef HAVE_MIXER
//#if !defined(_WIN32_WCE)
#define SOUND SOUND_MIXER
#define NOHS // No HW3SOUND
#ifdef HW3SOUND
#undef HW3SOUND
#endif
//#endif
#endif
// Use generic SDL interface.
@ -70,7 +68,7 @@
#endif
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#define ASMCALL __cdecl
#else
#define ASMCALL
@ -87,13 +85,6 @@
// warning C4152: nonstandard extension, function/data pointer conversion in expression
// warning C4213: nonstandard extension used : cast on l-value
#if defined (_WIN32_WCE) && defined (DEBUG) && defined (ARM)
#if defined (ARMV4) || defined (ARMV4I)
//#pragma warning(disable : 1166)
// warning LNK1166: cannot adjust code at offset=
#endif
#endif
#include "doomtype.h"
@ -110,13 +101,11 @@
#include <locale.h>
#endif
#if !defined (_WIN32_WCE)
#include <sys/types.h>
#include <sys/stat.h>
#endif
#include <ctype.h>
#if (defined (_WIN32) && !defined (_WIN32_WCE)) || defined (__DJGPP__)
#if defined (_WIN32) || defined (__DJGPP__)
#include <io.h>
#endif
@ -381,13 +370,11 @@ enum {
};
// Name of local directory for config files and savegames
#if !defined(_WIN32_WCE)
#if (((defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)) && !defined (__APPLE__)
#define DEFAULTDIR ".srb2"
#else
#define DEFAULTDIR "srb2"
#endif
#endif
#include "g_state.h"

View file

@ -17,7 +17,7 @@
#ifndef __DOOMTYPE__
#define __DOOMTYPE__
#if defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))
#ifdef _WIN32
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
@ -107,15 +107,6 @@ typedef long ssize_t;
#undef strnicmp
#define strnicmp(x,y,n) strncasecmp(x,y,n)
#endif
#ifdef _WIN32_WCE
#ifndef __GNUC__
#define stricmp(x,y) _stricmp(x,y)
#define strnicmp _strnicmp
#endif
#define strdup _strdup
#define strupr _strupr
#define strlwr _strlwr
#endif
#if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap
#define true 1
@ -167,7 +158,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz);
//faB: clean that up !!
#if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward
#include "stdbool.h"
#elif defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))
#elif defined (_WIN32)
#define false FALSE // use windows types
#define true TRUE
#define boolean BOOL

View file

@ -21,11 +21,7 @@
#define RPC_NO_WINDOWS_H
#include <windows.h>
#endif
#ifdef _WIN32_WCE
#include "sdl12/SRB2CE/cehelp.h"
#else
#include <sys/stat.h>
#endif
#include <string.h>
#include "filesrch.h"
@ -34,7 +30,7 @@
#include "z_zone.h"
#include "m_menu.h" // Addons_option_Onchange
#if (defined (_WIN32) && !defined (_WIN32_WCE)) && defined (_MSC_VER)
#if defined (_WIN32) && defined (_MSC_VER)
#include <errno.h>
#include <io.h>
@ -338,63 +334,6 @@ UINT8 refreshdirmenu = 0;
size_t packetsizetally = 0;
size_t mainwadstally = 0;
#ifdef _WIN32_WCE
filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum,
boolean completepath, int maxsearchdepth)
{
#ifdef __GNUC__
//NONE?
startpath = filename = NULL;
wantedmd5sum = NULL;
maxsearchdepth = 0;
completepath = false;
#else
WIN32_FIND_DATA dta;
HANDLE searchhandle = INVALID_HANDLE_VALUE;
const wchar_t wm[4] = L"*.*";
//if (startpath) SetCurrentDirectory(startpath);
if (FIL_ReadFileOK(filename))
{
// checkfilemd5 returns an FS_* value, either FS_FOUND or FS_MD5SUMBAD
return checkfilemd5(filename, wantedmd5sum);
}
ZeroMemory(&dta,sizeof (dta));
if (maxsearchdepth)
searchhandle = FindFirstFile(wm,&dta);
if (searchhandle != INVALID_HANDLE_VALUE)
{
do
{
if ((dta.cFileName[0]!='.') && (dta.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
//if (SetCurrentDirectory(dta.cFileName))
{ // can fail if we haven't the right
filestatus_t found;
found = filesearch(filename,NULL,wantedmd5sum,completepath,maxsearchdepth-1);
//SetCurrentDirectory("..");
if (found == FS_FOUND || found == FS_MD5SUMBAD)
{
if (completepath)
strcatbf(filename,(char *)dta.cFileName,"\\");
FindClose(searchhandle);
return found;
}
}
}
} while (FindNextFile(searchhandle,&dta)==0);
FindClose(searchhandle);
}
#endif
return FS_NOTFOUND;
}
boolean preparefilemenu(boolean samedepth)
{
(void)samedepth;
return false;
}
#else
filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, boolean completepath, int maxsearchdepth)
{
filestatus_t retval = FS_NOTFOUND;
@ -747,4 +686,3 @@ boolean preparefilemenu(boolean samedepth)
return true;
}
#endif

View file

@ -27,7 +27,7 @@
#define HAVE_IPV6
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#define USE_WINSOCK
#if defined (_WIN64) || defined (HAVE_IPV6)
#define USE_WINSOCK2
@ -164,11 +164,6 @@ static UINT8 UPNP_support = TRUE;
// winsock stuff (in winsock a socket is not a file)
#define ioctl ioctlsocket
#define close closesocket
#ifdef _WIN32_WCE
#include "sdl12/SRB2CE/cehelp.h"
#endif
#endif
#include "i_addrinfo.h"

View file

@ -157,7 +157,7 @@ typedef const u8 *LZF_STATE[1 << (HLOG)];
* lzfP.h ends here. lzf_d.c follows.
*/
#if AVOID_ERRNO || defined(_WIN32_WCE)
#if AVOID_ERRNO
# define SET_ERRNO(n)
#else
# include <errno.h>

View file

@ -20,11 +20,6 @@
#include <stdlib.h>
#endif
// Was this just for the #define USEASM?
//#ifdef _WIN32_WCE
//#include "sdl12/SRB2CE/cehelp.h"
//#endif
/*!
\brief bits of the fraction
*/

View file

@ -19,9 +19,7 @@
#endif
#include <string.h>
#ifndef _WIN32_WCE
#include <sys/types.h>
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4127)
#endif
@ -30,7 +28,7 @@
#include <stdlib.h>
#else
#ifndef HAVE_MEMCPY
#if !((defined (_WIN32) || defined (_WIN32_WCE)) && !defined (__CYGWIN__)) && !defined (__APPLE__)
#if !(defined (_WIN32) && !defined (__CYGWIN__)) && !defined (__APPLE__)
#define memcpy(d, s, n) bcopy ((s), (d), (n))
#endif
#endif

View file

@ -16,9 +16,7 @@
#include <errno.h>
#endif
#if !defined (UNDER_CE)
#include <time.h>
#endif
#if (defined (NOMD5) || defined (NOMSERV)) && !defined (NONET)
#define NONET
@ -30,7 +28,7 @@
#define HAVE_IPV6
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#define RPC_NO_WINDOWS_H
#ifdef HAVE_IPV6
#include <ws2tcpip.h>
@ -55,7 +53,7 @@
#include <sys/time.h> // timeval,... (TIMEOUT)
#include <errno.h>
#endif // _WIN32/_WIN32_WCE
#endif // _WIN32
#ifdef __OS2__
#include <errno.h>
@ -76,10 +74,6 @@
#include "m_argv.h" // Alam is going to kill me <3
#include "m_misc.h" // GetRevisionString()
#ifdef _WIN32_WCE
#include "sdl12/SRB2CE/cehelp.h"
#endif
#include "i_addrinfo.h"
// ================================ DEFINITIONS ===============================
@ -168,13 +162,13 @@ typedef struct
#endif
// win32 or djgpp
#if defined (_WIN32) || defined (_WIN32_WCE) || defined (__DJGPP__)
#if defined (_WIN32) || defined (__DJGPP__)
#define ioctl ioctlsocket
#define close closesocket
#ifdef WATTCP
#define strerror strerror_s
#endif
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#undef errno
#define errno h_errno // some very strange things happen when not using h_error
#endif
@ -200,7 +194,7 @@ static enum { MSCS_NONE, MSCS_WAITING, MSCS_REGISTERED, MSCS_FAILED } con_state
static INT32 msnode = -1;
UINT16 current_port = 0;
#if (defined (_WIN32) || defined (_WIN32_WCE) || defined (_WIN32)) && !defined (NONET)
#if defined (_WIN32) && !defined (NONET)
typedef SOCKET SOCKET_TYPE;
#define BADSOCKET INVALID_SOCKET
#define ERRSOCKET (SOCKET_ERROR)

View file

@ -65,7 +65,7 @@
#include "lua_script.h"
#include "lua_hook.h"
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#include <malloc.h>
#include <math.h>
#endif

View file

@ -40,11 +40,7 @@
#endif
// Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog
#ifdef _WIN32_WCE
#define AVOID_ERRNO
#else
#include <errno.h>
#endif
mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint
mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs

View file

@ -25,7 +25,7 @@
#include "v_video.h" // pMasterPalette
#include "dehacked.h"
#if defined (_WIN32) || defined (_WIN32_WCE)
#ifdef _WIN32
#include <malloc.h> // alloca(sizeof)
#endif

View file

@ -62,9 +62,7 @@ consvar_t sndserver_arg = {"sndserver_arg", "-quiet", CV_SAVE, NULL, 0, NULL, NU
#define SURROUND
#endif
#if defined (_WIN32_WCE)
consvar_t cv_samplerate = {"samplerate", "11025", 0, CV_Unsigned, NULL, 11025, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
#elif defined(_WINDOWS)
#ifdef _WINDOWS
consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 44100, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
#else
consvar_t cv_samplerate = {"samplerate", "22050", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking?
@ -91,11 +89,7 @@ static void Captioning_OnChange(void)
consvar_t cv_closedcaptioning = {"closedcaptioning", "Off", CV_SAVE|CV_CALL, CV_OnOff, Captioning_OnChange, 0, NULL, NULL, 0, 0, NULL};
// number of channels available
#if defined (_WIN32_WCE)
consvar_t cv_numChannels = {"snd_channels", "8", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
#else
consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
#endif
static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -1377,10 +1371,6 @@ static boolean S_DigMusic(const char *mname, boolean looping)
void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping)
{
#if defined (_WIN32_WCE)
S_ClearSfx();
#endif
if ((nomidimusic || music_disabled) && (nodigimusic || digital_disabled))
return;

View file

@ -15,20 +15,16 @@
#include "command.h"
#if (defined (_WIN32) || defined (_WIN32_WCE)) && !defined (__CYGWIN__)
#if defined (_WIN32_WCE) && defined (__GNUC__)
#include <sys/wcetypes.h>
#else
#if defined (_WIN32) && !defined (__CYGWIN__)
#define RPC_NO_WINDOWS_H
#include <windows.h>
#endif
#define DNWH HWND
#else
#define DNWH void * // unused in DOS version
#endif
// quickhack for V_Init()... to be cleaned up
#if defined (_WIN32_WCE) || defined (NOPOSTPROCESSING)
#ifdef NOPOSTPROCESSING
#define NUMSCREENS 2
#else
#define NUMSCREENS 5

View file

@ -14,10 +14,6 @@ ifdef PANDORA
include sdl12/SRB2Pandora/Makefile.cfg
endif #ifdef PANDORA
ifdef WINCE
include sdl12/SRB2CE/Makefile.cfg
endif #ifef WINCE
ifdef CYGWIN32
include sdl12/MakeCYG.cfg
endif #ifdef CYGWIN32

View file

@ -13,17 +13,8 @@
#include <malloc.h> /* For _alloca() */
#include <tchar.h>
#ifdef _WIN32_WCE
# define DIR_SEPERATOR TEXT("\\")
# define _tgetcwd(str,len) wcscpy(str,TEXT(""))
# define setbuf(f,b)
# define setvbuf(w,x,y,z)
# define _tremove(x) DeleteFile(x)
#else
# define DIR_SEPERATOR TEXT("/")
# include <direct.h>
#endif
/* Include the SDL main definition header */
#ifdef _MSC_VER
@ -44,45 +35,14 @@
#endif /* main */
/* The standard output files */
//#ifdef _WIN32_WCE
//#define STDOUT_FILE TEXT("/Storage Card/SRB2DEMO/stdout.txt")
//#define STDERR_FILE TEXT("/Storage Card/SRB2DEMO/stderr.txt")
//#else
#define STDOUT_FILE TEXT("stdout.txt")
#define STDERR_FILE TEXT("stderr.txt")
//#endif
#ifndef NO_STDIO_REDIRECT
static TCHAR stdoutPath[MAX_PATH];
static TCHAR stderrPath[MAX_PATH];
#endif
#if defined(_WIN32_WCE) && _WIN32_WCE < 300
/* seems to be undefined in Win CE although in online help */
#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t'))
/* seems to be undefined in Win CE although in online help */
char *strrchr(char *str, int c)
{
char *p;
/* Skip to the end of the string */
p=str;
while (*p)
p++;
/* Look for the given character */
while ( (p >= str) && (*p != (CHAR)c) )
p--;
/* Return NULL if character not found */
if ( p < str ) {
p = NULL;
}
return p;
}
#endif /* _WIN32_WCE < 300 */
/* Parse a command line buffer into arguments */
static int ParseCommandLine(char *cmdline, char **argv)
{
@ -191,7 +151,7 @@ static void __cdecl cleanup_output(void)
#endif
}
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
#if defined(_MSC_VER)
/* The VC++ compiler needs main defined */
#define console_main main
#endif
@ -268,23 +228,14 @@ int console_main(int argc, char *argv[])
}
/* This is where execution begins [windowed apps] */
#ifdef _WIN32_WCE
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw)
#else
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#endif
{
HINSTANCE handle;
int Result = -1;
char **argv;
int argc;
LPSTR cmdline;
#ifdef _WIN32_WCE
size_t nLen;
LPTSTR bufp;
#else
LPSTR bufp;
#endif
#ifndef NO_STDIO_REDIRECT
FILE *newfp;
#endif
@ -307,7 +258,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
/* Redirect standard input and standard output */
newfp = _tfreopen(stdoutPath, TEXT("w"), stdout);
#ifndef _WIN32_WCE
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stdout)
stdout = _tfopen(stdoutPath, TEXT("w"));
@ -318,13 +268,11 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
}
#endif
}
#endif /* _WIN32_WCE */
_tgetcwd( stderrPath, sizeof( stderrPath ) );
_tcscat( stderrPath, DIR_SEPERATOR STDERR_FILE );
newfp = _tfreopen(stderrPath, TEXT("w"), stderr);
#ifndef _WIN32_WCE
if ( newfp == NULL ) { /* This happens on NT */
#if !defined(stderr)
stderr = _tfopen(stderrPath, TEXT("w"));
@ -335,26 +283,11 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
}
#endif
}
#endif /* _WIN32_WCE */
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */
setbuf(stderr, NULL); /* No buffering */
#endif /* !NO_STDIO_REDIRECT */
#ifdef _WIN32_WCE
nLen = wcslen(szCmdLine)+128+1;
bufp = (wchar_t *)alloca(nLen*2);
wcscpy (bufp, TEXT("\""));
GetModuleFileName(NULL, bufp+1, 128-3);
wcscpy (bufp+wcslen(bufp), TEXT("\" "));
wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp));
nLen = wcslen(bufp)+1;
cmdline = (char *)alloca(nLen);
if ( cmdline == NULL ) {
return OutOfMemory();
}
WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL);
#else
szCmdLine = NULL;
/* Grab the command line (use alloca() on Windows) */
bufp = GetCommandLineA();
@ -363,7 +296,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
return OutOfMemory();
}
strcpy(cmdline, bufp);
#endif
/* Parse it into argv and argc */
argc = ParseCommandLine(cmdline, NULL);
@ -382,18 +314,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
#endif
/* Run the main program (after a little SDL initialization) */
#ifndef _WIN32_WCE
__try
#endif
{
Result = console_main(argc, argv);
}
#ifndef _WIN32_WCE
__except ( RecordExceptionInfo(GetExceptionInformation()))
{
SetUnhandledExceptionFilter(EXCEPTION_CONTINUE_SEARCH); //Do nothing here.
}
#endif
#ifdef BUGTRAP
} /* BT failure clause. */

View file

@ -1,12 +0,0 @@
#
# Makefile.cfg for WinCE with GCC
#
OPTS+=-D_WIN32_WCE -D_UNICODE
SDL_CFLAGS?=
SDL_LDFLAGS?=
NOHS=1
NOHW=1
NONET=1
NOMIXER=1
NOPNG=1

Binary file not shown.

View file

@ -1,446 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// DESCRIPTION:
// stub and replacement "ANSI" C functions for use under Windows CE
//
//-----------------------------------------------------------------------------
#include "../../doomdef.h"
#include "cehelp.h"
#define _SEC_IN_MINUTE 60
#define _SEC_IN_HOUR 3600
#define _SEC_IN_DAY 86400
static const int DAYS_IN_MONTH[12] =
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x])
static const int _DAYS_BEFORE_MONTH[12] =
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0))
#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365)
char *strerror(int ecode)
{
static char buff[1024 + 1];
DWORD dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
ecode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &buff[0], 1024, NULL);
return buff;
}
int unlink( const char *filename )
{
return remove(filename);
}
int remove( const char *path )
{
return DeleteFileA(path)-1;
}
int rename( const char *oldname, const char *newname )
{
return MoveFileA(oldname, newname)!=0;
}
static inline void STToTM(const SYSTEMTIME *st, struct tm *tm)
{
if (!st || !tm) return;
tm->tm_sec = st->wSecond;
tm->tm_min = st->wMinute;
tm->tm_hour = st->wHour;
tm->tm_mday = st->wDay;
tm->tm_mon = st->wMonth - 1;
tm->tm_year = st->wYear - 1900;
tm->tm_wday = st->wDayOfWeek;
tm->tm_yday = 0;
tm->tm_isdst = 0;
}
time_t time(time_t *T)
{
time_t returntime;
SYSTEMTIME st;
struct tm stft;
GetSystemTime(&st);
STToTM(&st,&stft);
returntime = mktime(&stft);
if (T) *T = returntime;
return returntime;
}
static inline UINT64 TTtoFT(const time_t wt, FILETIME *ft)
{
UINT64 temptime = wt; // FILETIME: 1/(10^7) secs since January 1, 1601
temptime *= 10000000; // time_t : 1 secs since January 1, 1970
// 369 years * 365 days * 24 hours * 60 mins * 60 secs * 10
// 123 leaps days * 24 hours * 60 mins * 60 secs * 10
temptime += 116444736000000000;
if (ft) CopyMemory(ft,&temptime,sizeof (ULARGE_INTEGER));
return temptime;
}
static struct tm cehelptm;
struct tm * localtime(const time_t *CLOCK)
{
SYSTEMTIME st;
FILETIME stft;
UINT64 ftli = 0;
if (CLOCK) ftli = TTtoFT(*CLOCK, &stft);
if (ftli)
FileTimeToSystemTime(&stft,&st);
else
GetSystemTime(&st);
STToTM(&st,&cehelptm);
if (st.wYear >= 1970)
return &cehelptm;
else
return NULL;
}
static void validate_structure (struct tm *tim_p) // from newlib
{
div_t res;
int days_in_feb = 28;
/* calculate time & date to account for out of range values */
if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59)
{
res = div (tim_p->tm_sec, 60);
tim_p->tm_min += res.quot;
if ((tim_p->tm_sec = res.rem) < 0)
{
tim_p->tm_sec += 60;
--tim_p->tm_min;
}
}
if (tim_p->tm_min < 0 || tim_p->tm_min > 59)
{
res = div (tim_p->tm_min, 60);
tim_p->tm_hour += res.quot;
if ((tim_p->tm_min = res.rem) < 0)
{
tim_p->tm_min += 60;
--tim_p->tm_hour;
}
}
if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23)
{
res = div (tim_p->tm_hour, 24);
tim_p->tm_mday += res.quot;
if ((tim_p->tm_hour = res.rem) < 0)
{
tim_p->tm_hour += 24;
--tim_p->tm_mday;
}
}
if (tim_p->tm_mon > 11)
{
res = div (tim_p->tm_mon, 12);
tim_p->tm_year += res.quot;
if ((tim_p->tm_mon = res.rem) < 0)
{
tim_p->tm_mon += 12;
--tim_p->tm_year;
}
}
if (_DAYS_IN_YEAR (tim_p->tm_year) == 366)
days_in_feb = 29;
if (tim_p->tm_mday <= 0)
{
while (tim_p->tm_mday <= 0)
{
if (--tim_p->tm_mon == -1)
{
tim_p->tm_year--;
tim_p->tm_mon = 11;
days_in_feb =
((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ?
29 : 28);
}
tim_p->tm_mday += _DAYS_IN_MONTH (tim_p->tm_mon);
}
}
else
{
while (tim_p->tm_mday > _DAYS_IN_MONTH (tim_p->tm_mon))
{
tim_p->tm_mday -= _DAYS_IN_MONTH (tim_p->tm_mon);
if (++tim_p->tm_mon == 12)
{
tim_p->tm_year++;
tim_p->tm_mon = 0;
days_in_feb =
((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ?
29 : 28);
}
}
}
}
time_t mktime (struct tm *tim_p) // from newlib
{
time_t tim = 0;
long days = 0;
int year;
/* validate structure */
validate_structure (tim_p);
/* compute hours, minutes, seconds */
tim += tim_p->tm_sec + (tim_p->tm_min * _SEC_IN_MINUTE) +
(tim_p->tm_hour * _SEC_IN_HOUR);
/* compute days in year */
days += tim_p->tm_mday - 1;
days += _DAYS_BEFORE_MONTH[tim_p->tm_mon];
if (tim_p->tm_mon > 1 && _DAYS_IN_YEAR (tim_p->tm_year) == 366)
days++;
/* compute day of the year */
tim_p->tm_yday = days;
if (tim_p->tm_year > 10000
|| tim_p->tm_year < -10000)
{
return (time_t) -1;
}
/* compute days in other years */
if (tim_p->tm_year > 70)
{
for (year = 70; year < tim_p->tm_year; year++)
days += _DAYS_IN_YEAR (year);
}
else if (tim_p->tm_year < 70)
{
for (year = 69; year > tim_p->tm_year; year--)
days -= _DAYS_IN_YEAR (year);
days -= _DAYS_IN_YEAR (year);
}
/* compute day of the week */
if ((tim_p->tm_wday = (days + 4) % 7) < 0)
tim_p->tm_wday += 7;
/* compute total seconds */
tim += (days * _SEC_IN_DAY);
return tim;
}
#undef WINAPI
#define WINAPI __stdcall //__delcspec(dllexport)
#ifdef _MSC_VER
//#pragma warning(disable : 4273)
#endif
static __forceinline int STRtoWSTR(LPCSTR lpMultiByteStr, int cchMultiByte,
LPWSTR lpWideCharStr, int cchWideChar)
{
return MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpMultiByteStr,
cchMultiByte,lpWideCharStr,cchWideChar);
}
static __forceinline int WSTRtoSTR(LPCWSTR lpWideCharStr, int cchWideChar,
LPSTR lpMultiByteStr, int cbMultiByte)
{
return WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK|WC_SEPCHARS,
lpWideCharStr,cchWideChar,lpMultiByteStr,cbMultiByte,NULL,NULL);
}
DWORD WINAPI FormatMessageA(
DWORD dwFlags,
LPCVOID lpSource,
DWORD dwMessageId,
DWORD dwLanguageId,
LPSTR lpBuffer,
DWORD nSize,
va_list *Arguments)
{
const int nSizeW = STRtoWSTR(lpBuffer,nSize,NULL,0);
int nSizeF = 0;
LPWSTR lpBufferW = alloca(sizeof (wchar_t)*nSizeW);
LPWSTR lpSourceW = NULL;
if (!lpBufferW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
ZeroMemory(lpBuffer,nSize);
return nSizeF;
}
if (dwFlags & FORMAT_MESSAGE_FROM_STRING)
{
const int sLen = STRtoWSTR(lpSource, -1, NULL, 0);
lpSourceW = alloca(sizeof (wchar_t)*sLen);
if (lpSourceW)
STRtoWSTR(lpSource, -1, lpSourceW, sLen);
else
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return nSizeF;
}
}
if (lpSourceW)
nSizeF = FormatMessageW(dwFlags, lpSourceW, dwMessageId, dwLanguageId,
lpBufferW, nSizeW, Arguments);
else
nSizeF = FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId,
lpBufferW, nSizeW, Arguments);
return WSTRtoSTR(lpBufferW, nSizeF, lpBuffer, nSize);
}
BOOL WINAPI DeleteFileA(
LPCSTR lpFileName)
{
const int sLen = STRtoWSTR(lpFileName, -1, NULL, 0);
LPWSTR lpFileNameW = alloca(sizeof (wchar_t)*sLen);
if (lpFileNameW)
STRtoWSTR(lpFileName, -1, lpFileNameW, sLen);
else
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
return DeleteFileW(lpFileNameW);
}
BOOL WINAPI MoveFileA(
LPCSTR lpExistingFileName,
LPCSTR lpNewFileName
)
{
const int sLen1 = STRtoWSTR(lpExistingFileName, -1, NULL, 0);
LPWSTR lpExistingFileNameW = alloca(sizeof (wchar_t)*sLen1);
const int sLen2 = STRtoWSTR(lpNewFileName, -1, NULL, 0);
LPWSTR lpNewFileNameW = alloca(sizeof (wchar_t)*sLen2);
if (!lpExistingFileNameW || !lpNewFileNameW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
STRtoWSTR(lpExistingFileName, -1, lpExistingFileNameW, sLen1);
STRtoWSTR(lpNewFileName, -1, lpNewFileNameW, sLen2);
return MoveFileW(lpExistingFileNameW, lpNewFileNameW);
}
HANDLE WINAPI CreateFileA(
LPCSTR lpFileName,
DWORD dwDesiredAccess,
DWORD dwShareMode,
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
DWORD dwCreationDisposition,
DWORD dwFlagsAndAttributes,
HANDLE hTemplateFile)
{
const int sLen = STRtoWSTR(lpFileName, -1, NULL, 0);
LPWSTR lpFileNameW = alloca(sizeof (wchar_t)*sLen);
if (lpFileNameW)
STRtoWSTR(lpFileName, -1, lpFileNameW, sLen);
else
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return INVALID_HANDLE_VALUE;
}
return CreateFileW(lpFileNameW, dwDesiredAccess, dwShareMode,
lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
hTemplateFile);
}
BOOL WINAPI CreateDirectoryA(
LPCSTR lpPathName,
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
{
const int sLen = STRtoWSTR(lpPathName, -1, NULL, 0);
LPWSTR lpPathNameW = alloca(sizeof (wchar_t)*sLen);
if (lpPathNameW)
STRtoWSTR(lpPathName, -1, lpPathNameW, sLen);
else
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
return CreateDirectoryW(lpPathNameW, lpSecurityAttributes);
}
int WINAPI MessageBoxA(
HWND hWnd ,
LPCSTR lpText,
LPCSTR lpCaption,
UINT uType)
{
const int sLen1 = STRtoWSTR(lpText, -1, NULL, 0);
LPWSTR lpTextW = alloca(sizeof (wchar_t)*sLen1);
const int sLen2 = STRtoWSTR(lpCaption, -1, NULL, 0);
LPWSTR lpCaptionW = alloca(sizeof (wchar_t)*sLen2);
if (!lpTextW || !lpCaptionW)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
STRtoWSTR(lpText, -1, lpTextW, sLen1);
STRtoWSTR(lpCaption, -1, lpCaptionW, sLen2);
return MessageBoxW(hWnd, lpTextW, lpCaptionW, uType);
}
VOID WINAPI OutputDebugStringA(
LPCSTR lpOutputString)
{
const int sLen = STRtoWSTR(lpOutputString, -1, NULL, 0);
LPWSTR lpOutputStringW = alloca(sizeof (wchar_t)*sLen);
if (lpOutputStringW)
STRtoWSTR(lpOutputString, -1, lpOutputStringW, sLen);
else
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return;
}
OutputDebugStringW(lpOutputStringW);
}

View file

@ -1,63 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004 by Sonic Team Jr.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// DESCRIPTION:
// stub and replacement "ANSI" C functions for use under Windows CE
//
//-----------------------------------------------------------------------------
#ifndef __I_WINCE__
#define __I_WINCE__
#ifdef USEASMCE
#define USEASM // Remline if NASM doesn't work on x86 targets
#endif
char *strerror(int ecode);
int access(const char *path, int amode);
int unlink( const char *filename );
int remove( const char *path );
int rename( const char *oldname, const char *newname );
//CreateDirectoryEx( const char *currectpath, const char *path,SECURITY_ATTRIBUTES)
#ifndef _TIME_T_DEFINED
typedef long time_t; /* time value */
#define _TIME_T_DEFINED /* avoid multiple def's of time_t */
#endif
time_t time(time_t *T);
#ifndef __GNUC__
#ifndef _TM_DEFINED
struct tm {
int tm_sec; /* seconds after the minute - [0,59] */
int tm_min; /* minutes after the hour - [0,59] */
int tm_hour; /* hours since midnight - [0,23] */
int tm_mday; /* day of the month - [1,31] */
int tm_mon; /* months since January - [0,11] */
int tm_year; /* years since 1900 */
int tm_wday; /* days since Sunday - [0,6] */
int tm_yday; /* days since January 1 - [0,365] */
int tm_isdst; /* daylight savings time flag */
};
#define _TM_DEFINED
#endif
struct tm * localtime(const time_t *CLOCK);
time_t mktime (struct tm *tim_p);
#endif
#endif

View file

@ -33,7 +33,6 @@
void ShowEndTxt(void)
{
#ifndef _WIN32_WCE
INT32 i;
UINT16 j, att = 0;
INT32 nlflag = 1;
@ -232,5 +231,4 @@ void ShowEndTxt(void)
printf("\n");
Z_Free(data);
#endif
}

View file

@ -19,10 +19,6 @@
#ifdef HAVE_SDL
#if defined (_WIN32_WCE)
#define NOSDLCD
#endif
#include <stdlib.h>
#ifndef NOSDLCD

View file

@ -58,7 +58,7 @@ FILE *logstream = NULL;
typedef BOOL (WINAPI *p_IsDebuggerPresent)(VOID);
#endif
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
static inline VOID MakeCodeWritable(VOID)
{
#ifdef USEASM // Disable write-protection of code segment
@ -121,9 +121,7 @@ int main(int argc, char **argv)
logdir = D_Home();
#ifdef LOGMESSAGES
#if defined(_WIN32_WCE)
logstream = fopen(va("%s.log",argv[0]), "a");
#elif defined (DEFAULTDIR)
#ifdef DEFAULTDIR
if (logdir)
logstream = fopen(va("%s/"DEFAULTDIR"/srb2log.txt",logdir), "a");
else
@ -134,7 +132,6 @@ int main(int argc, char **argv)
//I_OutputMsg("I_StartupSystem() ...\n");
I_StartupSystem();
#ifdef _WIN32
#ifndef _WIN32_WCE
{
p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent");
if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent())
@ -146,11 +143,8 @@ int main(int argc, char **argv)
LoadLibraryA("exchndl.dll");
}
}
#endif
prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo);
#ifndef _WIN32_WCE
MakeCodeWritable();
#endif
#endif
// startup SRB2
CONS_Printf("%s", M_GetText("Setting up SRB2...\n"));

View file

@ -20,15 +20,12 @@
/// \file
/// \brief SRB2 system stuff for SDL
#ifndef _WIN32_WCE
#include <signal.h>
#endif
#ifdef _WIN32
#define RPC_NO_WINDOWS_H
#include <windows.h>
#include "../doomtype.h"
#ifndef _WIN32_WCE
typedef BOOL (WINAPI *p_GetDiskFreeSpaceExA)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
typedef BOOL (WINAPI *p_IsProcessorFeaturePresent) (DWORD);
typedef DWORD (WINAPI *p_timeGetTime) (void);
@ -39,7 +36,6 @@ typedef HANDLE (WINAPI *p_GetCurrentProcess) (VOID);
typedef BOOL (WINAPI *p_GetProcessAffinityMask) (HANDLE, PDWORD_PTR, PDWORD_PTR);
typedef BOOL (WINAPI *p_SetProcessAffinityMask) (HANDLE, DWORD_PTR);
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -53,7 +49,7 @@ typedef BOOL (WINAPI *p_SetProcessAffinityMask) (HANDLE, DWORD_PTR);
#endif
#include <stdio.h>
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
#include <conio.h>
#endif
@ -111,7 +107,7 @@ typedef BOOL (WINAPI *p_SetProcessAffinityMask) (HANDLE, DWORD_PTR);
#include <wchar.h>
#endif
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
#define HAVE_MUMBLE
#define WINMUMBLE
#elif defined (HAVE_SHM)
@ -119,10 +115,6 @@ typedef BOOL (WINAPI *p_SetProcessAffinityMask) (HANDLE, DWORD_PTR);
#endif
#endif // NOMUMBLE
#ifdef _WIN32_WCE
#include "SRB2CE/cehelp.h"
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
@ -136,11 +128,6 @@ typedef BOOL (WINAPI *p_SetProcessAffinityMask) (HANDLE, DWORD_PTR);
#define DEFAULTSEARCHPATH1 "/usr/local/games"
#define DEFAULTSEARCHPATH2 "/usr/games"
#define DEFAULTSEARCHPATH3 "/usr/local"
#elif defined (_WIN32_WCE)
#define NOCWD
#define NOHOME
#define DEFAULTWADLOCATION1 "\\Storage Card\\SRB2DEMO"
#define DEFAULTSEARCHPATH1 "\\Storage Card"
#elif defined (_WIN32)
#define DEFAULTWADLOCATION1 "c:\\games\\srb2"
#define DEFAULTWADLOCATION2 "\\games\\srb2"
@ -275,7 +262,7 @@ static void signal_handler(INT32 num)
}
#endif
#if defined (NDEBUG) && !defined (_WIN32_WCE)
#if defined (NDEBUG)
FUNCNORETURN static ATTRNORETURN void quit_handler(int num)
{
signal(num, SIG_DFL); //default signal action
@ -495,7 +482,7 @@ void I_GetConsoleEvents(void)
(void)d;
}
#elif defined (_WIN32) && !defined (_WIN32_WCE)
#elif defined (_WIN32)
static BOOL I_ReadyConsole(HANDLE ci)
{
DWORD gotinput;
@ -709,7 +696,7 @@ void I_OutputMsg(const char *fmt, ...)
}
#endif
#if defined (_WIN32) && !defined(_WIN32_WCE)
#ifdef _WIN32
#ifdef DEBUGFILE
if (debugfile != stderr)
#endif
@ -1966,7 +1953,7 @@ ticcmd_t *I_BaseTiccmd2(void)
return &emptycmd2;
}
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
static HMODULE winmm = NULL;
static DWORD starttickcount = 0; // hack for win2k time bug
static p_timeGetTime pfntimeGetTime = NULL;
@ -2045,12 +2032,7 @@ tic_t I_GetTime (void)
ticks -= basetime;
ticks = (ticks*TICRATE);
#if 0 //#ifdef _WIN32_WCE
ticks = (ticks/10);
#else
ticks = (ticks/1000);
#endif
return (tic_t)ticks;
}
@ -2061,7 +2043,7 @@ tic_t I_GetTime (void)
//
void I_StartupTimer(void)
{
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
// for win2k time bug
if (M_CheckParm("-gettickcount"))
{
@ -2184,7 +2166,7 @@ static boolean shutdowning = false;
void I_Error(const char *error, ...)
{
va_list argptr;
#if defined (MAC_ALERT) || defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))
#if defined (MAC_ALERT) || defined (_WIN32)
char buffer[8192];
#endif
@ -2222,11 +2204,10 @@ void I_Error(const char *error, ...)
va_end(argptr);
// 2004-03-03 AJR Since the Mac user is most likely double clicking to run the game, give them a panel.
MacShowAlert("Recursive Error", buffer, "Quit", NULL, NULL);
#elif defined (_WIN32) || (defined (_WIN32_WCE)) && !defined (__GNUC__)
#elif defined (_WIN32)
va_start(argptr,error);
vsprintf(buffer, error, argptr);
va_end(argptr);
#ifndef _WIN32_WCE
{
HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD bytesWritten;
@ -2238,7 +2219,6 @@ void I_Error(const char *error, ...)
WriteFile(co, buffer, (DWORD)strlen(buffer), &bytesWritten, NULL);
}
}
#endif
OutputDebugStringA(buffer);
MessageBoxA(vid.WndParent, buffer, "SRB2 Recursive Error", MB_OK|MB_ICONERROR);
#else
@ -2387,7 +2367,7 @@ void I_GetDiskFreeSpace(INT64 *freespace)
}
*freespace = stfs.f_bavail * stfs.f_bsize;
#endif
#elif defined (_WIN32) && !defined (_WIN32_WCE)
#elif defined (_WIN32)
static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL;
static boolean testwin95 = false;
ULARGE_INTEGER usedbytes, lfreespace;
@ -2418,7 +2398,6 @@ void I_GetDiskFreeSpace(INT64 *freespace)
char *I_GetUserName(void)
{
#if !defined (_WIN32_WCE)
static char username[MAXPLAYERNAME];
char *p;
#ifdef _WIN32
@ -2450,7 +2429,6 @@ char *I_GetUserName(void)
if (strcmp(username, "") != 0)
return username;
#endif
return NULL; // dummy for platform independent version
}
@ -2459,7 +2437,7 @@ INT32 I_mkdir(const char *dirname, INT32 unixright)
//[segabor]
#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (__CYGWIN__) || defined (__OS2__)
return mkdir(dirname, unixright);
#elif defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))
#elif defined (_WIN32)
UNREFERENCED_PARAMETER(unixright); /// \todo should implement ntright under nt...
return CreateDirectoryA(dirname, NULL);
#else
@ -2473,9 +2451,6 @@ char *I_GetEnv(const char *name)
{
#ifdef NEED_SDL_GETENV
return SDL_getenv(name);
#elif defined(_WIN32_WCE)
(void)name;
return NULL;
#else
return getenv(name);
#endif
@ -2485,8 +2460,6 @@ INT32 I_PutEnv(char *variable)
{
#ifdef NEED_SDL_GETENV
return SDL_putenv(variable);
#elif defined(_WIN32_WCE)
return ((variable)?-1:0);
#else
return putenv(variable);
#endif
@ -2597,15 +2570,6 @@ static const char *locateWad(void)
if (((envstr = I_GetEnv("SRB2WADDIR")) != NULL) && isWadPathOk(envstr))
return envstr;
#if defined(_WIN32_WCE)
// examine argv[0]
strcpy(returnWadPath, myargv[0]);
pathonly(returnWadPath);
I_PutEnv(va("HOME=%s",returnWadPath));
if (isWadPathOk(returnWadPath))
return returnWadPath;
#endif
#ifndef NOCWD
I_OutputMsg(",.");
// examine current dir
@ -2703,9 +2667,9 @@ const char *I_LocateWad(void)
if (waddir)
{
// change to the directory where we found srb2.srb
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
SetCurrentDirectoryA(waddir);
#elif !defined (_WIN32_WCE)
#else
if (chdir(waddir) == -1)
I_OutputMsg("Couldn't change working directory\n");
#endif
@ -2803,7 +2767,7 @@ UINT32 I_GetFreeMem(UINT32 *total)
if (total)
*total = totalKBytes << 10;
return freeKBytes << 10;
#elif defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))
#elif defined (_WIN32)
MEMORYSTATUS info;
info.dwLength = sizeof (MEMORYSTATUS);
@ -2831,7 +2795,7 @@ UINT32 I_GetFreeMem(UINT32 *total)
const CPUInfoFlags *I_CPUInfo(void)
{
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
static CPUInfoFlags WIN_CPUInfo;
SYSTEM_INFO SI;
p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent");
@ -2892,7 +2856,7 @@ const CPUInfoFlags *I_CPUInfo(void)
#endif
}
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
static void CPUAffinity_OnChange(void);
static consvar_t cv_cpuaffinity = {"cpuaffinity", "-1", CV_SAVE | CV_CALL, NULL, CPUAffinity_OnChange, 0, NULL, NULL, 0, 0, NULL};
@ -2935,7 +2899,7 @@ static void CPUAffinity_OnChange(void)
void I_RegisterSysCommands(void)
{
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
GetAffinityFuncs();
CV_RegisterVar(&cv_cpuaffinity);
#endif

View file

@ -18,10 +18,7 @@
/// \brief SRB2 graphics stuff for SDL
#include <stdlib.h>
#ifndef _WIN32_WCE
#include <signal.h>
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4214 4244)
@ -49,7 +46,7 @@
#ifdef HAVE_IMAGE
#include "SDL_image.h"
#elseif !defined (_WIN32_WCE)
#else
#define LOAD_XPM //I want XPM!
#include "IMG_xpm.c" //Alam: I don't want to add SDL_Image.dll/so
#define HAVE_IMAGE //I have SDL_Image, sortof
@ -94,11 +91,7 @@
#endif
// maximum number of windowed modes (see windowedModes[][])
#if defined (_WIN32_WCE)
#define MAXWINMODES (1)
#else
#define MAXWINMODES (27)
#endif
/** \brief
*/
@ -141,25 +134,16 @@ static SDL_Rect **modeList = NULL;
static Uint8 BitsPerPixel = 16;
static Uint16 realwidth = BASEVIDWIDTH;
static Uint16 realheight = BASEVIDHEIGHT;
#ifdef _WIN32_WCE
static const Uint32 surfaceFlagsW = SDL_HWPALETTE; //Can't handle WinCE changing sides
#else
static const Uint32 surfaceFlagsW = SDL_HWPALETTE/*|SDL_RESIZABLE*/;
#endif
static const Uint32 surfaceFlagsF = SDL_HWPALETTE|SDL_FULLSCREEN;
static SDL_bool mousegrabok = SDL_TRUE;
#define HalfWarpMouse(x,y) SDL_WarpMouse((Uint16)(x/2),(Uint16)(y/2))
#if defined (_WIN32_WCE)
static SDL_bool videoblitok = SDL_TRUE;
#else
static SDL_bool videoblitok = SDL_FALSE;
#endif
static SDL_bool exposevideo = SDL_FALSE;
// windowed video modes from which to choose from.
static INT32 windowedModes[MAXWINMODES][2] =
{
#if !defined (_WIN32_WCE)
{1920,1200}, // 1.60,6.00
{1680,1050}, // 1.60,5.25
{1600,1200}, // 1.33,5.00
@ -186,17 +170,12 @@ static INT32 windowedModes[MAXWINMODES][2] =
{ 416, 312}, // 1.33,1.30
{ 400, 300}, // 1.33,1.25
{ 320, 240}, // 1.33,1.00
#endif
{ 320, 200}, // 1.60,1.00
};
static void SDLSetMode(INT32 width, INT32 height, INT32 bpp, Uint32 flags)
{
const char *SDLVD = I_GetEnv("SDL_VIDEODRIVER");
#ifdef _WIN32_WCE
if (bpp < 16)
bpp = 16; // 256 mode poo
#endif
#ifdef FILTERS
bpp = Setupf2x(width, height, bpp);
#endif
@ -233,17 +212,6 @@ static INT32 SDLatekey(SDLKey sym)
{
INT32 rc = sym + 0x80;
#ifdef _WIN32_WCE
if (sym == SDLK_KP8)
sym = SDLK_UP;
else if (sym == SDLK_KP4)
sym = SDLK_LEFT;
else if (sym == SDLK_KP6)
sym = SDLK_RIGHT;
else if (sym == SDLK_KP2)
sym = SDLK_DOWN;
#endif
switch (sym)
{
case SDLK_LEFT:
@ -586,7 +554,6 @@ static void VID_Command_Info_f (void)
static void VID_Command_ModeList_f(void)
{
#if !defined (_WIN32_WCE)
INT32 i;
#ifdef HWRENDER
if (rendermode == render_opengl)
@ -620,7 +587,6 @@ static void VID_Command_ModeList_f(void)
modeList[modeNum]->h);
}
CONS_Printf("%s", M_GetText("None\n"));
#endif
}
static void VID_Command_Mode_f (void)
@ -641,7 +607,7 @@ static void VID_Command_Mode_f (void)
setmodeneeded = modenum+1; // request vid mode change
}
#if defined(RPC_NO_WINDOWS_H) && !defined(_WIN32_WCE)
#ifdef RPC_NO_WINDOWS_H
static VOID MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(hWnd);
@ -962,7 +928,6 @@ void I_GetEvent(void)
SDLJoyRemap(&event);
if (event.type != ev_console) D_PostEvent(&event);
break;
#ifndef _WIN32_WCE
case SDL_QUIT:
if (!sdlquit)
{
@ -970,8 +935,7 @@ void I_GetEvent(void)
M_QuitResponse('y');
}
break;
#endif
#if defined(RPC_NO_WINDOWS_H) && !defined(_WIN32_WCE)
#ifdef RPC_NO_WINDOWS_H
case SDL_SYSWMEVENT:
MainWndproc(inputEvent.syswm.msg->hwnd,
inputEvent.syswm.msg->msg,
@ -1492,9 +1456,7 @@ static void SDLWMSet(void)
SetFocus(vid.WndParent);
ShowWindow(vid.WndParent, SW_SHOW);
}
#ifndef _WIN32_WCE
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
#endif
#endif
SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
}
@ -1513,9 +1475,6 @@ static void* SDLGetDirect(void)
INT32 VID_SetMode(INT32 modeNum)
{
#ifdef _WIN32_WCE
(void)modeNum;
#else
SDLdoUngrabMouse();
vid.recalc = true;
BitsPerPixel = (Uint8)cv_scr_depth.value;
@ -1614,7 +1573,6 @@ INT32 VID_SetMode(INT32 modeNum)
#if 0 // broken
if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT))
vid.height = (INT32)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match
#endif
#endif
I_StartupMouse();
@ -1696,11 +1654,7 @@ void I_StartupGraphics(void)
#endif
// Window title
#ifdef _WIN32_WCE
SDL_WM_SetCaption("SRB2 "VERSIONSTRING, "SRB2");
#else
SDL_WM_SetCaption("SRB2: Starting up", "SRB2");
#endif
// Window icon
#ifdef HAVE_IMAGE
@ -1744,7 +1698,7 @@ void I_StartupGraphics(void)
// check gl renderer lib
if (HWD.pfnGetRenderVersion() != VERSION)
I_Error("%s", M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n"));
#if 1 //#ifdef _WIN32_WCE
#if 1 //
vid.width = BASEVIDWIDTH;
vid.height = BASEVIDHEIGHT;
#else

View file

@ -49,7 +49,7 @@
#define MIX_CHANNELS 8
#endif
#if defined (_WIN32) && !defined (_WIN32_WCE)
#ifdef _WIN32
#include <direct.h>
#elif defined (__GNUC__)
#include <unistd.h>
@ -85,19 +85,11 @@
// mixing buffer, and the samplerate of the raw data.
// Needed for calling the actual sound output.
#if defined (_WIN32_WCE)
#define NUM_CHANNELS MIX_CHANNELS
#else
#define NUM_CHANNELS MIX_CHANNELS*4
#endif
#define INDEXOFSFX(x) ((sfxinfo_t *)x - S_sfx)
#if defined (_WIN32_WCE)
static Uint16 samplecount = 512; //Alam: .5KB samplecount at 11025hz is 46.439909297052154195011337868481ms of buffer
#else
static Uint16 samplecount = 1024; //Alam: 1KB samplecount at 22050hz is 46.439909297052154195011337868481ms of buffer
#endif
typedef struct chan_struct
{
@ -167,9 +159,6 @@ static SDL_bool canlooping = SDL_TRUE;
#if SDL_MIXER_VERSION_ATLEAST(1,2,7)
#define USE_RWOPS // ok, USE_RWOPS is in here
#if defined (_WIN32_WCE) //|| defined(_WIN32)
#undef USE_RWOPS
#endif
#endif
#if SDL_MIXER_VERSION_ATLEAST(1,2,10)

View file

@ -18,11 +18,7 @@
#define ZWAD
#ifdef ZWAD
#ifdef _WIN32_WCE
#define AVOID_ERRNO
#else
#include <errno.h>
#endif
#include "lzf.h"
#endif

View file

@ -1,174 +0,0 @@
/*
GameX - WindowsCE Game Library for High Performance.
Copyright (C) 1999 Hayes C. Haugen, all rights reserved.
*/
/*
* Need better way for host app to keep track of direct vs blit
drawing. Right now GetFBAddress() is the way to do it.
*/
#pragma once
#include <windows.h> // For VK codes.
// Defines
// display property flags
const unsigned long kfDPGrey = 0x0001;
const unsigned long kfDPGrey2Bit = 0x0002;
const unsigned long kfDPGrey4Bit = 0x0004;
const unsigned long kfDPColor = 0x0008;
const unsigned long kfDPColor8Bit = 0x0010;
const unsigned long kfDPColor16Bit = 0x0020;
const unsigned long kfDPColor24Bit = 0x0040;
const unsigned long kfDPColor32Bit = 0x0080;
const unsigned long kfDPFormatNormal = 0x0100; // fb start is upper left, inc goes across
const unsigned long kfDPFormatRot270 = 0x0200; // fb start is lower left, inc goes up
// Machine property flags
const unsigned long kfMPPSPC = 0x0001; // Palm Sized PC - 240 x 320
const unsigned long kfMPPSPC1 = 0x0002; // 1st gen pspc
const unsigned long kfMPPSPC2 = 0x0004; // Wyverns
const unsigned long kfMPHPC = 0x0008; // Handheld PC
const unsigned long kfMPHPC1 = 0x0010; // HPC 1, 480 x 240
const unsigned long kfMPHPC2 = 0x0020; // HPC 2, 640 x 240
const unsigned long kfMPHPC3 = 0x0040; // HPC Pro, 640 x 240, big keys
const unsigned long kfMPPro = 0x0080; //
const unsigned long kfMPAutoPC = 0x0100;
const unsigned long kfMPHasKeyboard = 0x0200;
const unsigned long kfMPHasMouse = 0x0400;
const unsigned long kfMPHasRumble = 0x0800;
const unsigned long kfMPHasTouch = 0x1000;
// Rotations
const int kiRotate0 = 0; // no rotation
const int kiRotate90 = 1; // 90 degrees clockwise
const int kiRotate180 = 2; // 180 degrees clockwise (upside down, Rotate 0 flipped)
const int kiRotate270 = 3; // 270 degrees clockwise (Rotate 1 flipped)
class GameX {
public:
HWND SetButtonNotificationWindow(HWND hWnd);
GameX();
~GameX();
bool OpenGraphics();
bool OpenSound();
bool OpenButtons(HWND hwndButtonNotify); // Window that will get button messages or NULL if you just want to use GetAsyncKeyState();
bool CloseGraphics();
bool CloseSound();
bool CloseButtons();
bool IsColor();
bool IsPSPC();
bool IsHPC();
bool IsHPCPro();
bool HasMouse();
bool HasKeyboard(); // better than inferring from hpc/pspc/etc.
bool HasRumble();
bool HasTouch(); // for completeness. At least 1 doesn't.
int IsForeground();
bool Suspend(); // release buttons, don't draw, etc.
bool Resume(); // regrab buttons, etc.
bool BeginDraw();
bool EndDraw();
bool FindFrameBuffer();
void * GetFBAddress(); // simple way to get things that makes code
long GetFBModulo(); // more readable.
long GetFBBpp();
bool GetScreenRect(RECT * prc);
unsigned long GetDisplayProperties();
bool GetButton(int VK); // buttons init themselves on first button call??
unsigned short GetDefaultButtonID(long id, long rotate); // gets the best button for use as specified by need and rotation
bool ReleaseButton(int VK);
bool BeginDetectButtons(); // grabs all buttons so user can indicate a button in a config dialog
bool EndDetectButtons(); // releases all buttons (except GetButton() ones)
bool Rumble();
bool Backlight(bool fOn);
private:
// LRESULT CALLBACK TaskBarWndProc(HWND hWnd, UINT message, WPARAM uParam, LPARAM lParam);
private:
int m_iMP; // index into amp table for current machine.
void * m_pvFrameBuffer;
long m_cbFBModulo; // count of bytes to next line
unsigned long m_ffMachineProperties;
unsigned long m_ffDisplayProperties;
int m_cBitsPP;
long m_dwPrevMode; // for Begin/EndDraw()
bool m_fActive; // true if active (resume), false if inactive (suspend).
HWND m_hwndTaskbar; // Taskbar is official cap, change TaskBar's
};
/*
kmtCasioE10
kmtCasioE11
kmtCasioE15
kmtCasioE55
kmtCasioE100
kmtLGPhenomII
stuff for memory size and presence/absence of CF
// Rotations that make sense for this device or default rotation:
Rotate0 // no rotation
Rotate1 // 90 degrees clockwise
Rotate2 // 180 degrees clockwise (upside down, Rotate 0 flipped)
Rotate3 // 270 degrees clockwise (Rotate 1 flipped)
kmtAccessNone // no direct framebuffer access
kmtAccess1 // write to fixed address
kmtAccess2 // find framebuffer memory aperture in GWES.EXE memory space.
OriginUpperLeft
OriginUpperRight
OriginLowerRight
OriginLowerLeft
MappedHorizontal // increasing fb address goes across screen
MappedVertical // increasing fb address goes up/down screen (Compaq)
A machine entry:
===========================================
machine kmtCasioE10,
type kmtPSPC | kmtPSPC1,
displaytype kmtGrey | kmtGrey2Bit | kmtAccess1,
pvFrameBuffer 0xAA000000,
cbFBModulo 1024 // count of bytes to next line
cbppFB 2, // bits per pixel
cxDisp 240,
cyDisp 320,
format OriginUpperLeft, MappedHorizontal
rotate0 // for rotate mode 0, these are the best keys
vkUp VK_UP
vkDown VK_DOWN
vkLeft 0xC1
vkRight 0xC2
vkA 0xC3
vkB 0
rotate1
vkUp 0xC1
vkDown 0xC2
vkLeft VK_DOWN
...
...*/

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 KiB

View file

@ -1,17 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief needed if mfc not installed (if I remember well)

View file

@ -1,129 +0,0 @@
#include <stdlib.h>
#include <windows.h>
#define _USE_GAPI_
#ifndef _USE_GAPI_
#include "GameX.h"
struct GXDisplayProperties
{
DWORD cxWidth;
DWORD cyHeight;
long cbxPitch;
long cbyPitch;
long cBPP;
DWORD ffFormat;
};
#define kfPalette 0x10 // Pixel values are indexes into a palette
#define kfDirect565 0x80 // 5 red bits, 6 green bits and 5 blue bits per pixel
GameX* gx = new GameX;
#else
#include "gx.h"
#endif
extern "C"
{
#include "gapi_c.h"
}
extern "C" int GXOPENDISPLAY(HWND hWnd, DWORD dwFlags)
{
#ifndef _USE_GAPI_
if(!gx)
return 0;
//gx->OpenSound();
if(!gx->OpenGraphics())
{
delete gx;
gx = 0;
return 0;
}
return TRUE;
#else
return GXOpenDisplay(hWnd,dwFlags);
#endif
}
extern "C" int GXCLOSEDISPLAY()
{
#ifndef _USE_GAPI_
gx->CloseGraphics();
return TRUE;
#else
return GXCloseDisplay();
#endif
}
extern "C" void * GXBEGINDRAW()
{
#ifndef _USE_GAPI_
if(gx->BeginDraw())
return gx->GetFBAddress();
return NULL;
#else
return GXBeginDraw();
#endif
}
extern "C" int GXENDDRAW()
{
#ifndef _USE_GAPI_
return gx->EndDraw();
#else
return GXEndDraw();
#endif
}
extern "C" struct GXDisplayProperties GXGETDISPLAYPROPERTIES()
{
#ifndef _USE_GAPI_
RECT r;
GXDisplayProperties gxdp;
gxdp.cbyPitch = gx->GetFBModulo();
gxdp.cBPP = gx->GetFBBpp();
gxdp.cbxPitch = (gxdp.cBPP >> 3);
gx->GetScreenRect(&r);
gxdp.cxWidth = (r.right - r.left);
gxdp.cyHeight = (r.bottom - r.top);
if(gxdp.cBPP = 16)
gxdp.ffFormat = kfDirect565;
else if(gxdp.cBPP = 8)
gxdp.ffFormat = kfPalette;
return gxdp;
#else
return GXGetDisplayProperties();
#endif
}
extern "C" int GXSUSPEND()
{
#ifndef _USE_GAPI_
return gx->Suspend();
#else
return GXSuspend();
#endif
}
extern "C" int GXRESUME()
{
#ifndef _USE_GAPI_
return gx->Resume();
#else
return GXResume();
#endif
}

View file

@ -1,12 +0,0 @@
#ifndef GAPI_H
#define GAPI_H
int GXOPENDISPLAY(HWND hWnd, DWORD dwFlags);
int GXCLOSEDISPLAY();
void * GXBEGINDRAW();
int GXENDDRAW();
struct GXDisplayProperties GXGETDISPLAYPROPERTIES();
int GXSUSPEND();
int GXRESUME();
#endif

View file

@ -1,636 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//-----------------------------------------------------------------------------
/// \file
/// \brief Zak Larue-Buckley's GX and GAPI library v1.0
#include "../doomdef.h"
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
#include <windowsx.h>
#include "../i_system.h"
#include "dx_error.h"
#include "fabdxlib.h"
#define NT4COMPAT //always defined, always compatible
// globals
IDirectDraw2* DDr2 = NULL;
IDirectDrawSurface* ScreenReal = NULL; // DirectDraw primary surface
IDirectDrawSurface* ScreenVirtual = NULL; // DirectDraw back surface
IDirectDrawPalette* DDPalette = NULL; // The primary surface palette
static IDirectDrawClipper *windclip = NULL; // clipper for windowed mode
BOOL bAppFullScreen; // true for fullscreen exclusive mode,
int windowPosX = 0; // current position in windowed mode
int windowPosY = 0;
int ScreenWidth;
int ScreenHeight;
BOOL ScreenLocked; // Screen surface is being locked
int ScreenPitch; // offset from one line to the next
LPBYTE ScreenPtr; // memory of the surface
//
// CreateNewSurface
//
static inline IDirectDrawSurface* CreateNewSurface(int dwWidth,
int dwHeight,
int dwSurfaceCaps)
{
DDSURFACEDESC ddsd;
HRESULT hr;
LPDIRECTDRAWSURFACE psurf;
ZeroMemory(&ddsd, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = dwSurfaceCaps;
ddsd.dwHeight = dwHeight;
ddsd.dwWidth = dwWidth;
hr = IDirectDraw2_CreateSurface (DDr2, &ddsd, &psurf, NULL);
if (hr == DD_OK)
{
//DDCOLORKEY ddck;
IDirectDrawSurface_Restore(psurf);
//hr = IDirectDrawSurface_GetColorKey(DDCKEY_SRCBLT, &ddck);
//psurf->SetColorKey(DDCKEY_SRCBLT, &ddck);
}
else
psurf = NULL;
return psurf;
}
//
// wow! from 320x200x8 up to 1600x1200x32 thanks Banshee! :)
//
static HRESULT WINAPI myEnumModesCallback (LPDDSURFACEDESC surf, LPVOID lpContext)
{
APPENUMMODESCALLBACK pfnContext = lpContext;
if (pfnContext) pfnContext(surf->dwWidth,
surf->dwHeight,surf->ddpfPixelFormat.
#ifdef DUMMYUNIONNAMEN
DUMMYUNIONNAMEN(1).
#endif
dwRGBBitCount
);
/*CONS_Printf ("%dx%dx%d bpp %d refresh\n",
surf->dwWidth,
surf->dwHeight,
surf->ddpfPixelFormat.dwRGBBitCount,
surf->dwRefreshRate);*/
return DDENUMRET_OK;
}
//
// Application call here to enumerate display modes
//
BOOL EnumDirectDrawDisplayModes (APPENUMMODESCALLBACK appFunc)
{
LPVOID lpappFunc = appFunc;
if (DDr2 == NULL)
return FALSE;
// enumerate display modes
// Carl: DirectX 3.x apparently does not support VGA modes. Who cares. :)
// faB: removed DDEDM_REFRESHRATES, detects too many modes, plus we don't care of refresh rate.
if (bDX0300)
IDirectDraw2_EnumDisplayModes (DDr2, 0 /*| DDEDM_REFRESHRATES*/,
NULL, lpappFunc, myEnumModesCallback);
else
IDirectDraw2_EnumDisplayModes (DDr2, DDEDM_STANDARDVGAMODES /*| DDEDM_REFRESHRATES*/,
NULL, lpappFunc, myEnumModesCallback);
return TRUE;
}
//
// Create the DirectDraw object for later
//
BOOL CreateDirectDrawInstance (VOID)
{
HRESULT hr;
IDirectDraw* DDr;
IDirectDraw** rp = &DDr;
IDirectDraw2** rp2 = &DDr2;
LPVOID *tp = (LPVOID *)rp2;
//
// create an instance of DirectDraw object
//
if (FAILED(hr = DirectDrawCreate(NULL, rp, NULL)))
I_Error("DirectDrawCreate FAILED: %s", DXErrorToString(hr));
// change interface to IDirectDraw2
if (FAILED(hr = IDirectDraw_QueryInterface (DDr, &IID_IDirectDraw2, tp)))
I_Error("Failed to query DirectDraw2 interface: %s", DXErrorToString(hr));
// release the interface we don't need
IDirectDraw_Release (DDr);
return TRUE;
}
//
// - returns true if DirectDraw was initialized properly
//
int InitDirectDrawe (HWND appWin, int width, int height, int bpp, int fullScr)
{
DDSURFACEDESC ddsd; // DirectDraw surface description for allocating
DDSCAPS ddscaps;
HRESULT ddrval;
DWORD dwStyle;
RECT rect;
// enumerate directdraw devices
//if (FAILED(DirectDrawEnumerate (myEnumDDDevicesCallback, NULL)))
// I_Error("Error with DirectDrawEnumerate");
if (!DDr2)
CreateDirectDrawInstance();
// remember what screen mode we are in
bAppFullScreen = fullScr;
ScreenHeight = height;
ScreenWidth = width;
if (bAppFullScreen)
{
// Change window attributes
dwStyle = WS_POPUP | WS_VISIBLE;
SetWindowLong (appWin, GWL_STYLE, dwStyle);
SetWindowPos(appWin, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE |
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
// Get exclusive mode
ddrval = IDirectDraw2_SetCooperativeLevel(DDr2, appWin, DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN |
DDSCL_ALLOWREBOOT);
if (ddrval != DD_OK)
I_Error("SetCooperativeLevel FAILED: %s\n", DXErrorToString(ddrval));
// Switch from windows desktop to fullscreen
#ifdef NT4COMPAT
ddrval = IDirectDraw2_SetDisplayMode(DDr2, width, height, bpp, 0, 0);
#else
ddrval = IDirectDraw2_SetDisplayMode(DDr2, width, height, bpp, 0, DDSDM_STANDARDVGAMODE);
#endif
if (ddrval != DD_OK)
I_Error("SetDisplayMode FAILED: %s\n", DXErrorToString(ddrval));
// This is not really needed, except in certain cases. One case
// is while using MFC. When the desktop is initally at 16bpp, a mode
// switch to 8bpp somehow causes the MFC window to not fully initialize
// and a CreateSurface will fail with DDERR_NOEXCLUSIVEMODE. This will
// ensure that the window is initialized properly after a mode switch.
ShowWindow(appWin, SW_SHOW);
// Create the primary surface with 1 back buffer. Always zero the
// DDSURFACEDESC structure and set the dwSize member!
ZeroMemory(&ddsd, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
// for fullscreen we use page flipping, for windowed mode, we blit the hidden surface to
// the visible surface, in both cases we have a visible (or 'real') surface, and a hidden
// (or 'virtual', or 'backbuffer') surface.
ddsd.dwBackBufferCount = 1;
ddrval = IDirectDraw2_CreateSurface(DDr2,&ddsd, &ScreenReal, NULL);
if (ddrval != DD_OK)
I_Error("CreateSurface Primary Screen FAILED");
// Get a pointer to the back buffer
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
ddrval = IDirectDrawSurface_GetAttachedSurface(ScreenReal,&ddscaps, &ScreenVirtual);
if (ddrval != DD_OK)
I_Error("GetAttachedSurface FAILED");
}
else
{
rect.top = 0;
rect.left = 0;
rect.bottom = height-1;
rect.right = width-1;
// Change window attributes
dwStyle = GetWindowStyle(appWin);
dwStyle &= ~WS_POPUP;
dwStyle |= WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION;
SetWindowLong(appWin, GWL_STYLE, dwStyle);
// Resize the window so that the client area is the requested width/height
AdjustWindowRectEx(&rect, GetWindowStyle(appWin), GetMenu(appWin) != NULL,
GetWindowExStyle(appWin));
// Just in case the window was moved off the visible area of the
// screen.
SetWindowPos(appWin, NULL, 0, 0, rect.right-rect.left,
rect.bottom-rect.top, SWP_NOMOVE | SWP_NOZORDER |
SWP_NOACTIVATE);
SetWindowPos(appWin, HWND_NOTOPMOST, 0, 0, 0, 0,
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
// Exclusive mode is normal since it's in windowed mode and needs
// to cooperate with GDI
ddrval = IDirectDraw2_SetCooperativeLevel(DDr2,appWin, DDSCL_NORMAL);
if (ddrval != DD_OK)
I_Error("SetCooperativeLevel FAILED");
// Always zero the DDSURFACEDESC structure and set the dwSize member!
ZeroMemory(&ddsd, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
// Create the primary surface
ddrval = IDirectDraw2_CreateSurface(DDr2,&ddsd, &ScreenReal, NULL);
if (ddrval != DD_OK)
I_Error("CreateSurface Primary Screen FAILED");
// Create a back buffer for offscreen rendering, this will be used to
// blt to the primary
ScreenVirtual = CreateNewSurface(width, height, DDSCAPS_OFFSCREENPLAIN |
DDSCAPS_SYSTEMMEMORY);
if (ScreenVirtual == NULL)
I_Error("CreateSurface Secondary Screen FAILED");
/// \todo get the desktop bit depth, and build a lookup table
/// for quick conversions of 8bit color indexes 0-255 to desktop colors
/// eg: 256 entries of equivalent of palette colors 0-255 in 15,16,24,32 bit format
/// when blit virtual to real, convert pixels through lookup table..
// Use a clipper object for clipping when in windowed mode
// (make sure our drawing doesn't affect other windows)
ddrval = IDirectDraw2_CreateClipper (DDr2, 0, &windclip, 0);
if (ddrval != DD_OK)
I_Error("CreateClipper FAILED");
// Associate the clipper with the window.
ddrval = IDirectDrawClipper_SetHWnd (windclip,0, appWin);
if (ddrval != DD_OK)
I_Error("Clipper -> SetHWnd FAILED");
// Attach the clipper to the surface.
ddrval = IDirectDrawSurface_SetClipper (ScreenReal,windclip);
if (ddrval != DD_OK)
I_Error("PrimaryScreen -> SetClipperClipper FAILED");
}
return TRUE;
}
//
// Free all memory
//
VOID CloseDirectDraw (VOID)
{
ReleaseChtuff();
if (DDr2)
{
IDirectDraw2_Release(DDr2);
DDr2 = NULL;
}
}
//
// Release DirectDraw stuff before display mode change
//
VOID ReleaseChtuff (VOID)
{
if (!DDr2)
return;
if (windclip)
{
IDirectDrawClipper_Release(windclip);
windclip = NULL;
}
if (DDPalette)
{
IDirectDrawPalette_Release(DDPalette);
DDPalette = NULL;
}
// If the app is fullscreen, the back buffer is attached to the
// primary. Releasing the primary buffer will also release any
// attached buffers, so explicitly releasing the back buffer is not
// necessary.
if (!bAppFullScreen && ScreenVirtual)
{
IDirectDrawSurface_Release(ScreenVirtual); // release hidden surface
ScreenVirtual = NULL;
}
if (ScreenReal)
{
IDirectDrawSurface_Release(ScreenReal); // and attached backbuffers for bAppFullScreen mode
ScreenReal = NULL;
}
}
//
// Clear the surface to color
//
VOID ClearSurface(IDirectDrawSurface* surface, int color)
{
DDBLTFX ddbltfx;
// Use the blter to do a color fill to clear the back buffer
ddbltfx.dwSize = sizeof (ddbltfx);
ddbltfx.
#ifdef DUMMYUNIONNAMEN
DUMMYUNIONNAMEN(5).
#endif
dwFillColor = color;
IDirectDrawSurface_Blt(surface,NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
}
//
// Flip the real page with virtual page
// - in bAppFullScreen mode, do page flipping
// - in windowed mode, copy the hidden surface to the visible surface
//
// waitflip : if not 0, wait for page flip to end
BOOL ScreenFlip(int waitflip)
{
HRESULT hr;
RECT rect;
waitflip = 0;
if (bAppFullScreen)
{
//hr = IDirectDrawSurface_GetFlipStatus (ScreenReal, DDGFS_);
// In full-screen exclusive mode, do a hardware flip.
hr = IDirectDrawSurface_Flip(ScreenReal, NULL, DDFLIP_WAIT); //return immediately
// If the surface was lost, restore it.
if (hr == DDERR_SURFACELOST)
{
IDirectDrawSurface_Restore(ScreenReal);
// The restore worked, so try the flip again.
hr = IDirectDrawSurface_Flip(ScreenReal, 0, DDFLIP_WAIT);
}
}
else
{
rect.left = windowPosX;
rect.top = windowPosY;
rect.right = windowPosX + ScreenWidth - 1;
rect.bottom = windowPosY + ScreenHeight - 1;
// Copy the back buffer to front.
hr = IDirectDrawSurface_Blt(ScreenReal, &rect, ScreenVirtual, 0, DDBLT_WAIT, 0);
if (hr != DD_OK)
{
// If the surfaces were lost, restore them.
if (IDirectDrawSurface_IsLost(ScreenReal) == DDERR_SURFACELOST)
IDirectDrawSurface_Restore(ScreenReal);
if (IDirectDrawSurface_IsLost(ScreenVirtual) == DDERR_SURFACELOST)
IDirectDrawSurface_Restore(ScreenVirtual);
// Retry the copy.
hr = IDirectDrawSurface_Blt(ScreenReal,&rect, ScreenVirtual, 0, DDBLT_WAIT, 0);
}
}
if (hr != DD_OK)
I_Error("ScreenFlip() : couldn't Flip surfaces");
return FALSE;
}
//
// Print a text to the surface
//
VOID TextPrint(int x, int y, LPCSTR message)
{
HRESULT hr;
HDC hdc = NULL;
// Get the device context handle.
hr = IDirectDrawSurface_GetDC(ScreenVirtual,&hdc);
if (hr != DD_OK)
return;
// Write the message.
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, RGB(255, 255, 255));
TextOutA(hdc, x, y, message, (int)strlen(message));
// Release the device context.
hr = IDirectDrawSurface_ReleaseDC(ScreenVirtual,hdc);
}
//
// Lock surface before multiple drawings by hand, for speed
//
boolean LockScreen(VOID)
{
DDSURFACEDESC ddsd;
HRESULT ddrval;
ZeroMemory(&ddsd, sizeof (ddsd));
ddsd.dwSize = sizeof (ddsd);
// attempt to Lock the surface
ddrval = IDirectDrawSurface_Lock(ScreenVirtual, NULL, &ddsd, DDLOCK_WAIT, NULL);
// Always, always check for errors with DirectX!
// If the surface was lost, restore it.
if (ddrval == DDERR_SURFACELOST)
{
ddrval = IDirectDrawSurface_Restore(ScreenReal);
// now retry to get the lock
ddrval = IDirectDrawSurface_Lock(ScreenVirtual, NULL, &ddsd, DDLOCK_WAIT, NULL);
}
if (ddrval == DD_OK)
{
ScreenLocked = TRUE;
ScreenPtr = (LPBYTE)ddsd.lpSurface;
ScreenPitch = ddsd.
#ifdef DUMMYUNIONNAMEN
DUMMYUNIONNAMEN(1).
#endif
lPitch;
}
else
{
ScreenLocked = FALSE;
ScreenPtr = NULL;
ScreenPitch = 0;
//I_Error("LockScreen() : couldn't restore the surface.");
return false;
}
return true;
}
//
// Unlock surface
//
VOID UnlockScreen(VOID)
{
if (DD_OK != IDirectDrawSurface_Unlock(ScreenVirtual,NULL))
I_Error("Couldn't UnLock the renderer!");
ScreenLocked = FALSE;
ScreenPtr = NULL;
ScreenPitch = 0;
}
// Blit virtual screen to real screen
//faB: note: testing 14/03/1999, see if it is faster than memcopy of virtual to
/*
static LPDIRECTDRAWSURFACE lpDDS = NULL;
VOID BlitScreen(VOID)
{
HRESULT hr;
if (!lpDDS)
I_Error("lpDDS NULL");
hr = IDirectDrawSurface_BltFast(ScreenVirtual,
0, 0, // Upper left xy of destination
lpDDS, // Source surface
NULL, // Source rectangle = entire surface
DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
if (FAILED(hr))
I_Error("BltFast FAILED");
}
VOID MakeScreen(int width, int height, BYTE* lpSurface)
{
HRESULT hr;
DDSURFACEDESC ddsd;
// Initialize the surface description.
ZeroMemory (&ddsd, sizeof ddsd);
ZeroMemory (&ddsd.ddpfPixelFormat, sizeof (DDPIXELFORMAT));
ddsd.dwSize = sizeof ddsd;
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | //DDSD_LPSURFACE |
DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_CAPS;
ddsd.dwWidth = width;
ddsd.dwHeight= height;
ddsd.lPitch = width;
ddsd.lpSurface = lpSurface;
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN;
// Set up the pixel format for 8-bit
ddsd.ddpfPixelFormat.dwSize = sizeof (DDPIXELFORMAT);
ddsd.ddpfPixelFormat.dwFlags= DDPF_RGB | DDPF_PALETTEINDEXED8;
ddsd.ddpfPixelFormat.dwRGBBitCount = 8;
//
ddsd.ddpfPixelFormat.dwRGBBitCount = (DWORD)DEPTH*8;
ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
// Create the surface
hr = IDirectDraw2_CreateSurface(DDr2, &ddsd, &lpDDS, NULL);
if (FAILED(hr))
I_Error("MakeScreen FAILED: %s",DDError(hr));
//ddsd.lpSurface = lpSurface;
}
*/
//
// Create a palette object
//
VOID CreateDDPalette (PALETTEENTRY* colorTable)
{
HRESULT ddrval;
ddrval = IDirectDraw2_CreatePalette(DDr2,DDPCAPS_8BIT|DDPCAPS_ALLOW256, colorTable, &DDPalette, NULL);
if (ddrval != DD_OK)
I_Error("couldn't CreatePalette");
};
//
// Free the palette object
//
VOID DestroyDDPalette (VOID)
{
if (DDPalette)
{
IDirectDrawPalette_Release(DDPalette);
DDPalette = NULL;
}
}
//
// Set a a full palette of 256 PALETTEENTRY entries
//
VOID SetDDPalette(PALETTEENTRY* pal)
{
// create palette first time
if (DDPalette == NULL)
CreateDDPalette(pal);
else
IDirectDrawPalette_SetEntries(DDPalette, 0, 0, 256, pal);
// setting the same palette to the same surface again does not increase
// the reference count
IDirectDrawSurface_SetPalette(ScreenReal, DDPalette);
}
//
// Wait for vsync, gross
//
VOID WaitVbl(VOID)
{
IDirectDraw2_WaitForVerticalBlank(DDr2, DDWAITVB_BLOCKBEGIN, NULL);
}

View file

@ -1,81 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief Zak Larue-Buckley's GX and GAPI library v1.0
#ifndef _H_GXGAPILIB_
#define _H_GXGAPILIB_
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
#ifdef __MINGW32__
//#define NONAMELESSUNION
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4201)
#endif
#include <ddraw.h>
#if (defined (DIRECTDRAW_VERSION) && (DIRECTDRAW_VERSION >= 0x0700))
#undef DUMMYUNIONNAMEN
#endif
// format of function in app called with width,height
typedef BOOL (*APPENUMMODESCALLBACK)(int width, int height, int bpp);
// globals
extern IDirectDraw2* DDr2;
extern IDirectDrawSurface* ScreenReal;
extern IDirectDrawSurface* ScreenVirtual;
extern IDirectDrawPalette* DDPalette;
extern BOOL bAppFullScreen; // main code might need this to know the current
// fullscreen or windowed state
extern int windowPosX; // current position in windowed mode
extern int windowPosY;
extern int ScreenWidth;
extern int ScreenHeight;
extern BOOL ScreenLocked; // Screen surface is being locked
extern int ScreenPitch; // offset from one line to the next
extern LPBYTE ScreenPtr; // memory of the surface
extern BOOL bDX0300;
BOOL EnumDirectDrawDisplayModes (APPENUMMODESCALLBACK appFunc);
BOOL CreateDirectDrawInstance (VOID);
int InitDirectDrawe (HWND appWin, int width, int height, int bpp, int fullScr);
VOID CloseDirectDraw (VOID);
VOID ReleaseChtuff (VOID);
VOID ClearSurface (IDirectDrawSurface* surface, int color);
BOOL ScreenFlip (int wait);
VOID TextPrint (int x, int y, LPCSTR message);
VOID CreateDDPalette (PALETTEENTRY* colorTable);
VOID DestroyDDPalette (VOID);
VOID SetDDPalette (PALETTEENTRY* pal);
VOID WaitVbl (VOID);
boolean LockScreen (VOID);
VOID UnlockScreen (VOID);
#endif /* _H_FABDXLIB_ */

View file

@ -1,150 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief MIDI structures and definitions
/// used by the MSTREAM sample application in
/// converting a MID file to a MIDI stream for
/// playback using the midiStream API.
/// Inpired by DirectX5 SDK examples
#ifndef __MIDSTUFF_H__
#define __MIDSTUFF_H__
// MIDI file constants
//
#define MThd 0x6468544D // Start of file
#define MTrk 0x6B72544D // Start of track
#define MIDI_SYSEX ((BYTE)0xF0) // SysEx begin
#define MIDI_SYSEXEND ((BYTE)0xF7) // SysEx begin
#define MIDI_META ((BYTE)0xFF) // Meta event begin
#define MIDI_META_TEMPO ((BYTE)0x51) // Tempo change
#define MIDI_META_EOT ((BYTE)0x2F) // End-of-track
#define MIDI_NOTEOFF ((BYTE)0x80) // + note + velocity
#define MIDI_NOTEON ((BYTE)0x90) // + note + velocity
#define MIDI_POLYPRESS ((BYTE)0xA0) // + pressure (2 bytes)
#define MIDI_CTRLCHANGE ((BYTE)0xB0) // + ctrlr + value
#define MIDI_PRGMCHANGE ((BYTE)0xC0) // + new patch
#define MIDI_CHANPRESS ((BYTE)0xD0) // + pressure (1 byte)
#define MIDI_PITCHBEND ((BYTE)0xE0) // + pitch bend (2 bytes)
#define NUM_CHANNELS 16
#define MIDICTRL_VOLUME ((BYTE)0x07)
#define MIDICTRL_VOLUME_LSB ((BYTE)0x27)
#define MIDICTRL_PAN ((BYTE)0x0A)
#define MIDIEVENT_CHANNEL(dw) (dw & 0x0000000F)
#define MIDIEVENT_TYPE(dw) (dw & 0x000000F0)
#define MIDIEVENT_DATA1(dw) ((dw & 0x0000FF00) >> 8)
#define MIDIEVENT_VOLUME(dw) ((dw & 0x007F0000) >> 16)
// Macros for swapping hi/lo-endian data
//
#define WORDSWAP(w) (((w) >> 8) | \
(((w) << 8) & 0xFF00))
#define DWORDSWAP(dw) (((dw) >> 24) | \
(((dw) >> 8) & 0x0000FF00) | \
(((dw) << 8) & 0x00FF0000) | \
(((dw) << 24) & 0xFF000000))
// In debug builds, TRACKERR will show us where the parser died
//
//#define TRACKERR(p,sz) ShowTrackError(p,sz);
#define TRACKERR(p,sz)
// Make a little distinction here so the various structure members are a bit
// more clearly labelled -- we have offsets and byte counts to keep track of
// that deal with both in-memory buffers and the file on disk
#define FILEOFF DWORD
// These structures are stored in MIDI files; they need to be byte aligned.
//
#if defined(_MSC_VER)
#pragma pack(1)
#endif
// Chunk header. dwTag is either MTrk or MThd.
//
typedef struct
{
DWORD dwTag; // Type
DWORD dwChunkLength; // Length (hi-lo)
} ATTRPACK MIDICHUNK;
// Contents of MThd chunk.
typedef struct
{
WORD wFormat; // Format (hi-lo)
WORD wTrackCount; // # tracks (hi-lo)
WORD wTimeDivision; // Time division (hi-lo)
} ATTRPACK MIDIFILEHDR;
#if defined(_MSC_VER)
#pragma pack() // End of need for byte-aligned structures
#endif
// Temporary event structure which stores event data until we're ready to
// dump it into a stream buffer
//
typedef struct
{
DWORD tkEvent; // Absolute time of event
BYTE byShortData[4]; // Event type and parameters if channel msg
DWORD dwEventLength; // Length of data which follows if meta or sysex
LPBYTE pLongData; // -> Event data if applicable
} TEMPEVENT, *PTEMPEVENT;
#define ITS_F_ENDOFTRK 0x00000001
// Description of a track open for read
//
typedef struct
{
DWORD fdwTrack; // Track status
DWORD dwTrackLength; // Total bytes in track
DWORD dwLeftInBuffer; // Bytes left unread in track buffer
LPBYTE pTrackStart; // -> start of track data buffer
LPBYTE pTrackCurrent; // -> next byte to read in buffer
DWORD tkNextEventDue; // Absolute time of next event in track
BYTE byRunningStatus;// Running status from last channel msg
FILEOFF foTrackStart; // Start of track -- used for walking the file
FILEOFF foNextReadStart;// File offset of next read from disk
DWORD dwLeftOnDisk; // Bytes left unread on disk
#ifdef DEBUG
DWORD nTrack; // # of this track for debugging
#endif
} INTRACKSTATE, *PINTRACKSTATE;
// Description of the input MIDI file
//
typedef struct
{
DWORD cbFileLength; // Total bytes in file
DWORD dwTimeDivision; // Original time division
DWORD dwFormat; // Original format
DWORD dwTrackCount; // Track count (specifies pitsTracks size)
INTRACKSTATE *pitsTracks; // -> array of tracks in this file
} INFILESTATE, *PINFILESTATE;
#endif //__MIDSTUFF_H__

View file

@ -1,18 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by Srb2win.rc
//
#define IDI_DLICON1 101
#define IDC_DLCURSOR1 103
#define IDI_ICON1 106
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 114
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -1,529 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief cd music interface (uses MCI).
#include "../doomdef.h"
#include "win_main.h"
#include <mmsystem.h>
#include "../command.h"
#include "../doomtype.h"
#include "../i_sound.h"
#include "../i_system.h"
#include "../s_sound.h"
#define MAX_CD_TRACKS 255
typedef struct {
BOOL IsAudio;
DWORD Start, End;
DWORD Length; // minutes
} CDTrack;
// -------
// private
// -------
static CDTrack m_nTracks[MAX_CD_TRACKS];
static int m_nTracksCount; // up to MAX_CD_TRACKS
static MCI_STATUS_PARMS m_MCIStatus;
static MCI_OPEN_PARMS m_MCIOpen;
// ------
// protos
// ------
static void Command_Cd_f (void);
// -------------------
// MCIErrorMessageBox
// Retrieve error message corresponding to return value from
// mciSendCommand() or mciSenString()
// -------------------
static VOID MCIErrorMessageBox (MCIERROR iErrorCode)
{
char szErrorText[128];
if (!mciGetErrorStringA (iErrorCode, szErrorText, sizeof (szErrorText)))
wsprintfA(szErrorText,"MCI CD Audio Unknow Error #%d\n", iErrorCode);
CONS_Printf (szErrorText);
/*MessageBox (GetActiveWindow(), szTemp+1, "LEGACY",
MB_OK | MB_ICONSTOP);*/
}
// --------
// CD_Reset
// --------
static void CD_Reset (void)
{
// no win32 equivalent
//faB: for DOS, some odd drivers like to be reset sometimes.. useless in MCI I guess
}
// ----------------
// CD_ReadTrackInfo
// Read in number of tracks, and length of each track in minutes/seconds
// returns true if error
// ----------------
static BOOL CD_ReadTrackInfo (void)
{
int i;
int nTrackLength;
MCIERROR iErr;
m_nTracksCount = 0;
m_MCIStatus.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM|MCI_WAIT, (DWORD_PTR)&m_MCIStatus);
if (iErr)
{
MCIErrorMessageBox (iErr);
return FALSE;
}
m_nTracksCount = (int)m_MCIStatus.dwReturn;
if (m_nTracksCount > MAX_CD_TRACKS)
m_nTracksCount = MAX_CD_TRACKS;
for (i = 0; i < m_nTracksCount; i++)
{
m_MCIStatus.dwTrack = (DWORD)(i+1);
m_MCIStatus.dwItem = MCI_STATUS_LENGTH;
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_STATUS, MCI_TRACK|MCI_STATUS_ITEM|MCI_WAIT, (DWORD_PTR)&m_MCIStatus);
if (iErr)
{
MCIErrorMessageBox (iErr);
return FALSE;
}
nTrackLength = (DWORD)(MCI_MSF_MINUTE(m_MCIStatus.dwReturn)*60 + MCI_MSF_SECOND(m_MCIStatus.dwReturn));
m_nTracks[i].Length = nTrackLength;
m_MCIStatus.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_STATUS, MCI_TRACK|MCI_STATUS_ITEM|MCI_WAIT, (DWORD_PTR)&m_MCIStatus);
if (iErr)
{
MCIErrorMessageBox (iErr);
return FALSE;
}
m_nTracks[i].IsAudio = (m_MCIStatus.dwReturn == MCI_CDA_TRACK_AUDIO);
}
return TRUE;
}
// ------------
// CD_TotalTime
// returns total time for all audio tracks in seconds
// ------------
static int CD_TotalTime (void)
{
int nTotalLength = 0;
int nTrack;
for (nTrack = 0; nTrack < m_nTracksCount; nTrack++)
{
if (m_nTracks[nTrack].IsAudio)
nTotalLength = nTotalLength + m_nTracks[nTrack].Length;
}
return nTotalLength;
}
//======================================================================
// CD AUDIO MUSIC SUBSYSTEM
//======================================================================
UINT8 cdaudio_started = 0; // for system startup/shutdown
static boolean cdPlaying = false;
static int cdPlayTrack; // when cdPlaying is true
static boolean cdLooping = false;
static UINT8 cdRemap[MAX_CD_TRACKS];
static boolean cdEnabled = true; // cd info available
static boolean cdValid; // true when last cd audio info was ok
static boolean wasPlaying;
//static int cdVolume = 0; // current cd volume (0-31)
// 0-31 like Music & Sfx, though CD hardware volume is 0-255.
consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
// allow Update for next/loop track
// some crap cd drivers take up to
// a second for a simple 'busy' check..
// (on those Update can be disabled)
consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
// hour,minutes,seconds
static char *hms(int seconds)
{
int hours, minutes;
static char s[9];
minutes = seconds / 60;
seconds %= 60;
hours = minutes / 60;
minutes %= 60;
if (hours > 0)
sprintf (s, "%d:%02d:%02d", hours, minutes, seconds);
else
sprintf (s, "%2d:%02d", minutes, seconds);
return s;
}
static void Command_Cd_f (void)
{
LPCSTR s;
int i,j;
if (!cdaudio_started)
return;
if (COM_Argc()<2)
{
CONS_Printf ("cd [on] [off] [remap] [reset] [open]\n"
" [info] [play <track>] [loop <track>]\n"
" [stop] [resume]\n");
return;
}
s = COM_Argv(1);
// activate cd music
if (!strncmp(s,"on",2))
{
cdEnabled = true;
return;
}
// stop/deactivate cd music
if (!strncmp(s,"off",3))
{
if (cdPlaying)
I_StopCD ();
cdEnabled = false;
return;
}
// remap tracks
if (!strncmp(s,"remap",5))
{
i = (int)COM_Argc() - 2;
if (i <= 0)
{
CONS_Printf ("CD tracks remapped in that order :\n");
for (j = 1; j < MAX_CD_TRACKS; j++)
if (cdRemap[j] != j)
CONS_Printf (" %2d -> %2d\n", j, cdRemap[j]);
return;
}
for (j = 1; j <= i; j++)
cdRemap[j] = (UINT8)atoi (COM_Argv (j+1));
return;
}
// reset the CD driver, useful on some odd cd's
if (!strncmp(s,"reset",5))
{
cdEnabled = true;
if (cdPlaying)
I_StopCD ();
for (i = 0; i < MAX_CD_TRACKS; i++)
cdRemap[i] = (UINT8)i;
CD_Reset();
cdValid = CD_ReadTrackInfo();
return;
}
// any other command is not allowed until we could retrieve cd information
if (!cdValid)
{
CONS_Printf ("CD is not ready.\n");
return;
}
/* faB: not with MCI, didn't find it, useless anyway
if (!strncmp(s,"open",4))
{
if (cdPlaying)
I_StopCD ();
bcd_open_door();
cdValid = false;
return;
}*/
if (!strncmp(s,"info",4))
{
if (!CD_ReadTrackInfo())
{
cdValid = false;
return;
}
cdValid = true;
if (m_nTracksCount <= 0)
CONS_Printf ("No audio tracks\n");
else
{
// display list of tracks
// highlight current playing track
for (i = 0; i < m_nTracksCount; i++)
{
CONS_Printf("%s%2d. %s %s\n",
cdPlaying && (cdPlayTrack == i) ? "\2 " : " ",
i+1, m_nTracks[i].IsAudio ? "audio" : "data ",
hms(m_nTracks[i].Length));
}
CONS_Printf ("\2Total time : %s\n", hms(CD_TotalTime()));
}
if (cdPlaying)
{
CONS_Printf ("%s track : %d\n", cdLooping ? "looping" : "playing",
cdPlayTrack);
}
return;
}
if (!strncmp(s,"play",4))
{
I_PlayCD ((UINT8)atoi(COM_Argv (2)), false);
return;
}
if (!strncmp(s,"stop",4))
{
I_StopCD ();
return;
}
if (!strncmp(s,"loop",4))
{
I_PlayCD ((UINT8)atoi(COM_Argv (2)), true);
return;
}
if (!strncmp(s,"resume",4))
{
I_ResumeCD ();
return;
}
CONS_Printf ("cd command '%s' unknown\n", s);
}
// ------------
// I_ShutdownCD
// Shutdown CD Audio subsystem, release whatever was allocated
// ------------
void I_ShutdownCD (void)
{
MCIERROR iErr;
if (!cdaudio_started)
return;
CONS_Printf("I_ShutdownCD()\n");
I_StopCD();
// closes MCI CD
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_CLOSE, 0, 0);
if (iErr)
MCIErrorMessageBox (iErr);
}
// --------
// I_InitCD
// Init CD Audio subsystem
// --------
void I_InitCD (void)
{
MCI_SET_PARMS mciSet;
MCIERROR iErr;
int i;
// We don't have an open device yet
m_MCIOpen.wDeviceID = 0;
m_nTracksCount = 0;
cdaudio_started = false;
m_MCIOpen.lpstrDeviceType = (LPCTSTR)MCI_DEVTYPE_CD_AUDIO;
iErr = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID, (DWORD_PTR)&m_MCIOpen);
if (iErr)
{
MCIErrorMessageBox (iErr);
return;
}
// Set the time format to track/minute/second/frame (TMSF).
mciSet.dwTimeFormat = MCI_FORMAT_TMSF;
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)&mciSet);
if (iErr)
{
MCIErrorMessageBox (iErr);
mciSendCommand(m_MCIOpen.wDeviceID, MCI_CLOSE, 0, 0);
return;
}
I_AddExitFunc (I_ShutdownCD);
cdaudio_started = true;
CONS_Printf("I_InitCD: Init CD audio\n");
// last saved in config.cfg
i = cd_volume.value;
//I_SetVolumeCD (0); // initialize to 0 for some odd cd drivers
I_SetVolumeCD (i); // now set the last saved volume
for (i = 0; i < MAX_CD_TRACKS; i++)
cdRemap[i] = (UINT8)i;
if (!CD_ReadTrackInfo())
{
CONS_Printf("\2I_InitCD: no CD in player.\n");
cdEnabled = false;
cdValid = false;
}
else
{
cdEnabled = true;
cdValid = true;
}
COM_AddCommand ("cd", Command_Cd_f);
}
// loop/go to next track when track is finished (if cd_update var is true)
// update the volume when it has changed (from console/menu)
void I_UpdateCD (void)
{
/// \todo check for cd change and restart music ?
}
//
void I_PlayCD (UINT8 nTrack, UINT8 bLooping)
{
MCI_PLAY_PARMS mciPlay;
MCIERROR iErr;
if (!cdaudio_started || !cdEnabled)
return;
//faB: try again if it didn't work (just free the user of typing 'cd reset' command)
if (!cdValid)
cdValid = CD_ReadTrackInfo();
if (!cdValid)
return;
// tracks start at 0 in the code..
nTrack--;
if (nTrack < 0 || nTrack >= m_nTracksCount)
nTrack = nTrack % m_nTracksCount;
nTrack = cdRemap[nTrack];
if (cdPlaying)
{
if (cdPlayTrack == nTrack)
return;
I_StopCD ();
}
cdPlayTrack = nTrack;
if (!m_nTracks[nTrack].IsAudio)
{
//CONS_Printf ("\2CD Play: not an audio track\n"); // Tails 03-25-2001
return;
}
cdLooping = bLooping;
//faB: stop MIDI music, MIDI music will restart if volume is upped later
cv_digmusicvolume.value = 0;
cv_midimusicvolume.value = 0;
I_StopSong (0);
//faB: I don't use the notify message, I'm trying to minimize the delay
mciPlay.dwCallback = (DWORD_PTR)((size_t)hWndMain);
mciPlay.dwFrom = MCI_MAKE_TMSF(nTrack+1, 0, 0, 0);
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_PLAY, MCI_FROM|MCI_NOTIFY, (DWORD_PTR)&mciPlay);
if (iErr)
{
MCIErrorMessageBox (iErr);
cdValid = false;
cdPlaying = false;
return;
}
cdPlaying = true;
}
// pause cd music
void I_StopCD (void)
{
MCIERROR iErr;
if (!cdaudio_started || !cdEnabled)
return;
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_PAUSE, MCI_WAIT, 0);
if (iErr)
MCIErrorMessageBox (iErr);
else
{
wasPlaying = cdPlaying;
cdPlaying = false;
}
}
// continue after a pause
void I_ResumeCD (void)
{
MCIERROR iErr;
if (!cdaudio_started || !cdEnabled)
return;
if (!cdValid)
return;
if (!wasPlaying)
return;
iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_RESUME, MCI_WAIT, 0);
if (iErr)
MCIErrorMessageBox (iErr);
else
cdPlaying = true;
}
// volume : logical cd audio volume 0-31 (hardware is 0-255)
int I_SetVolumeCD (int volume)
{
(void)volume;
return 1;
}

View file

@ -1,629 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief Sources from GameDeveloper magazine article, January 1998, by Bruce Dawson.
/// this source file contains the exception handler for recording error
/// information after crashes.
#include <tchar.h>
#include "win_main.h"
#include "../doomdef.h" //just for VERSION
#include "win_dbg.h"
#include "../m_argv.h" //print the parameter in the log
#define NumCodeBytes 16 // Number of code bytes to record.
#define MaxStackDump 2048 // Maximum number of DWORDS in stack dumps.
#define StackColumns 8 // Number of columns in stack dump.
#define ONEK 1024
#define SIXTYFOURK (64*ONEK)
#define ONEM (ONEK*ONEK)
#define ONEG (ONEK*ONEK*ONEK)
// --------------------------------------------------------------------------
// return a description for an ExceptionCode
// --------------------------------------------------------------------------
static LPCSTR GetExceptionDescription (DWORD ExceptionCode)
{
unsigned int i;
struct ExceptionNames
{
DWORD ExceptionCode;
LPCSTR ExceptionName;
};
struct ExceptionNames ExceptionMap[] =
{
{EXCEPTION_ACCESS_VIOLATION, "an Access Violation"},
{EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "a Array Bounds Exceeded"},
{EXCEPTION_BREAKPOINT, "a Breakpoint"},
{EXCEPTION_DATATYPE_MISALIGNMENT, "a Datatype Misalignment"},
{EXCEPTION_FLT_DENORMAL_OPERAND, "a Float Denormal Operand"},
{EXCEPTION_FLT_DIVIDE_BY_ZERO, "a Float Divide By Zero"},
{EXCEPTION_FLT_INEXACT_RESULT, "a Float Inexact Result"},
{EXCEPTION_FLT_INVALID_OPERATION, "a Float Invalid Operation"},
{EXCEPTION_FLT_OVERFLOW, "a Float Overflow"},
{EXCEPTION_FLT_STACK_CHECK, "a Float Stack Check"},
{EXCEPTION_FLT_UNDERFLOW, "a Float Underflow"},
{EXCEPTION_ILLEGAL_INSTRUCTION, "an Illegal Instruction"},
{EXCEPTION_IN_PAGE_ERROR, "an In Page Error"},
{EXCEPTION_INT_DIVIDE_BY_ZERO, "an Integer Divide By Zero"},
{EXCEPTION_INT_OVERFLOW, "an Integer Overflow"},
{EXCEPTION_INVALID_DISPOSITION, "an Invalid Disposition"},
{EXCEPTION_NONCONTINUABLE_EXCEPTION, "Noncontinuable Exception"},
{EXCEPTION_PRIV_INSTRUCTION, "a Privileged Instruction"},
{EXCEPTION_SINGLE_STEP, "a Single Step"},
{EXCEPTION_STACK_OVERFLOW, "a Stack Overflow"},
{0x40010005, "a Control-C"},
{0x40010008, "a Control-Break"},
{0xc0000006, "an In Page Error"},
{0xc0000017, "a No Memory"},
{0xc000001d, "an Illegal Instruction"},
{0xc0000025, "a Noncontinuable Exception"},
{0xc0000142, "a DLL Initialization Failed"},
{0xe06d7363, "a Microsoft C++ Exception"},
};
for (i = 0; i < (sizeof (ExceptionMap) / sizeof (ExceptionMap[0])); i++)
if (ExceptionCode == ExceptionMap[i].ExceptionCode)
return ExceptionMap[i].ExceptionName;
return "Unknown exception type";
}
// --------------------------------------------------------------------------
// Directly output a formatted string to the errorlog file, using win32 funcs
// --------------------------------------------------------------------------
static VOID FPrintf (HANDLE fileHandle, LPCSTR lpFmt, ...)
{
CHAR str[1999];
va_list arglist;
DWORD bytesWritten;
va_start (arglist, lpFmt);
vsprintf (str, lpFmt, arglist);
va_end (arglist);
WriteFile (fileHandle, str, (DWORD)strlen(str), &bytesWritten, NULL);
}
// --------------------------------------------------------------------------
// Print the specified FILETIME to output in a human readable format,
// without using the C run time.
// --------------------------------------------------------------------------
static VOID PrintTime (LPSTR output, FILETIME TimeToPrint)
{
WORD Date, Time;
if (FileTimeToLocalFileTime (&TimeToPrint, &TimeToPrint) &&
FileTimeToDosDateTime (&TimeToPrint, &Date, &Time))
{
// What a silly way to print out the file date/time.
wsprintfA(output, "%d/%d/%d %02d:%02d:%02d",
(Date / 32) & 15, Date & 31, (Date / 512) + 1980,
(Time / 2048), (Time / 32) & 63, (Time & 31) * 2);
}
else
output[0] = 0;
}
static LPTSTR GetFilePart(LPTSTR source)
{
LPTSTR result = _tcsrchr(source, '\\');
if (result)
result++;
else
result = source;
return result;
}
// --------------------------------------------------------------------------
// Print information about a code module (DLL or EXE) such as its size,
// location, time stamp, etc.
// --------------------------------------------------------------------------
static VOID ShowModuleInfo(HANDLE LogFile, HMODULE ModuleHandle)
{
CHAR ModName[MAX_PATH];
IMAGE_DOS_HEADER *DosHeader;
IMAGE_NT_HEADERS *NTHeader;
HANDLE ModuleFile;
CHAR TimeBuffer[100] = "";
DWORD FileSize = 0;
#ifdef NO_SEH_MINGW
__try1(EXCEPTION_EXECUTE_HANDLER)
#else
__try
#endif
{
if (GetModuleFileNameA(ModuleHandle, ModName, sizeof (ModName)) > 0)
{
// If GetModuleFileName returns greater than zero then this must
// be a valid code module address. Therefore we can try to walk
// our way through its structures to find the link time stamp.
DosHeader = (IMAGE_DOS_HEADER*)ModuleHandle;
if (IMAGE_DOS_SIGNATURE != DosHeader->e_magic)
return;
NTHeader = (IMAGE_NT_HEADERS*)((char *)DosHeader
+ DosHeader->e_lfanew);
if (IMAGE_NT_SIGNATURE != NTHeader->Signature)
return;
// Open the code module file so that we can get its file date
// and size.
ModuleFile = CreateFileA(ModName, GENERIC_READ,
FILE_SHARE_READ, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
if (ModuleFile != INVALID_HANDLE_VALUE)
{
FILETIME LastWriteTime;
FileSize = GetFileSize(ModuleFile, 0);
if (GetFileTime(ModuleFile, 0, 0, &LastWriteTime))
{
wsprintfA(TimeBuffer, " - file date is ");
PrintTime(TimeBuffer + strlen(TimeBuffer), LastWriteTime);
}
CloseHandle(ModuleFile);
}
FPrintf (LogFile, "%s, loaded at 0x%08x - %d bytes - %08x%s\r\n",
ModName, ModuleHandle, FileSize,
NTHeader->FileHeader.TimeDateStamp, TimeBuffer);
}
}
// Handle any exceptions by continuing from this point.
#ifdef NO_SEH_MINGW
__except1
#else
__except(EXCEPTION_EXECUTE_HANDLER)
#endif
{
}
}
// --------------------------------------------------------------------------
// Scan memory looking for code modules (DLLs or EXEs). VirtualQuery is used
// to find all the blocks of address space that were reserved or committed,
// and ShowModuleInfo will display module information if they are code
// modules.
// --------------------------------------------------------------------------
static VOID RecordModuleList(HANDLE LogFile)
{
SYSTEM_INFO SystemInfo;
size_t PageSize;
size_t NumPages;
size_t pageNum = 0;
LPVOID LastAllocationBase = 0;
FPrintf (LogFile, "\r\n"
"\tModule list: names, addresses, sizes, time stamps "
"and file times:\r\n");
// Set NumPages to the number of pages in the 4GByte address space,
// while being careful to avoid overflowing ints.
GetSystemInfo(&SystemInfo);
PageSize = SystemInfo.dwPageSize;
NumPages = 4 * (unsigned int)(ONEG / PageSize);
while (pageNum < NumPages)
{
MEMORY_BASIC_INFORMATION MemInfo;
if (VirtualQuery((LPVOID)(pageNum * PageSize), &MemInfo,
sizeof (MemInfo)))
{
if (MemInfo.RegionSize > 0)
{
// Adjust the page number to skip over this block of memory.
pageNum += MemInfo.RegionSize / PageSize;
if (MemInfo.State == MEM_COMMIT && MemInfo.AllocationBase >
LastAllocationBase)
{
// Look for new blocks of committed memory, and try
// recording their module names - this will fail
// gracefully if they aren't code modules.
LastAllocationBase = MemInfo.AllocationBase;
ShowModuleInfo(LogFile, (HMODULE)LastAllocationBase);
}
}
else
pageNum += SIXTYFOURK / PageSize;
}
else
pageNum += SIXTYFOURK / PageSize;
// If VirtualQuery fails we advance by 64K because that is the
// granularity of address space doled out by VirtualAlloc().
}
}
// --------------------------------------------------------------------------
// Record information about the user's system, such as processor type, amount
// of memory, etc.
// --------------------------------------------------------------------------
static VOID RecordSystemInformation(HANDLE fileHandle)
{
FILETIME CurrentTime;
CHAR TimeBuffer[100];
CHAR ModuleName[MAX_PATH];
CHAR UserName[200];
DWORD UserNameSize;
SYSTEM_INFO SystemInfo;
MEMORYSTATUS MemInfo;
GetSystemTimeAsFileTime (&CurrentTime);
PrintTime (TimeBuffer, CurrentTime);
FPrintf(fileHandle, "Error occurred at %s.\r\n", TimeBuffer);
if (GetModuleFileNameA(NULL, ModuleName, sizeof (ModuleName)) <= 0)
strcpy (ModuleName, "Unknown");
UserNameSize = sizeof (UserName);
if (!GetUserNameA(UserName, &UserNameSize))
strcpy (UserName, "Unknown");
FPrintf(fileHandle, "%s, run by %s.\r\n", ModuleName, UserName);
GetSystemInfo (&SystemInfo);
FPrintf (fileHandle, "%d processor(s), type %d %d.%d.\r\n"
"Program Memory from 0x%p to 0x%p\r\n",
SystemInfo.dwNumberOfProcessors,
SystemInfo.dwProcessorType,
SystemInfo.wProcessorLevel,
SystemInfo.wProcessorRevision,
SystemInfo.lpMinimumApplicationAddress,
SystemInfo.lpMaximumApplicationAddress);
MemInfo.dwLength = sizeof (MemInfo);
GlobalMemoryStatus(&MemInfo);
// Print out the amount of physical memory, rounded up.
FPrintf(fileHandle, "%d MBytes physical memory.\r\n", (MemInfo.dwTotalPhys +
ONEM - 1) / ONEM);
}
// --------------------------------------------------------------------------
// What we do here is trivial : open a file, write out the register information
// from the PEXCEPTION_POINTERS structure, then return EXCEPTION_CONTINUE_SEARCH
// whose magic value tells Win32 to proceed with its normal error handling
// mechanism. This is important : an error dialog will popup if possible and
// the debugger will hopefully coexist peacefully with the structured exception
// handler.
// --------------------------------------------------------------------------
int __cdecl RecordExceptionInfo (PEXCEPTION_POINTERS data/*, LPCSTR Message, LPSTR lpCmdLine*/)
{
PEXCEPTION_RECORD Exception;
PCONTEXT Context;
TCHAR ModuleName[MAX_PATH];
TCHAR FileName[MAX_PATH] = TEXT("Unknown");
LPTSTR FilePart, lastperiod;
TCHAR CrashModulePathName[MAX_PATH];
LPCTSTR CrashModuleFileName = TEXT("Unknown");
MEMORY_BASIC_INFORMATION MemInfo;
static int BeenHere = false;
HANDLE fileHandle;
UINT8 *code;
int codebyte,i;
if (data)
{
Exception = data->ExceptionRecord;
Context = data->ContextRecord;
}
else
{
return EXCEPTION_CONTINUE_SEARCH;
}
if (BeenHere) // Going recursive! That must mean this routine crashed!
return EXCEPTION_CONTINUE_SEARCH;
BeenHere = true;
// Create a filename to record the error information to.
// Store it in the executable directory.
if (GetModuleFileName(NULL, ModuleName, sizeof (ModuleName)) <= 0)
ModuleName[0] = 0;
FilePart = GetFilePart(ModuleName);
// Extract the file name portion and remove it's file extension. We'll
// use that name shortly.
lstrcpy (FileName, FilePart);
lastperiod = _tcsrchr (FileName, '.');
if (lastperiod)
lastperiod[0] = 0;
// Replace the executable filename with our error log file name.
lstrcpy (FilePart, TEXT("errorlog.txt"));
fileHandle = CreateFile (ModuleName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL);
if (fileHandle == INVALID_HANDLE_VALUE)
{
OutputDebugString (TEXT("Error creating exception report"));
return EXCEPTION_CONTINUE_SEARCH;
}
// Append to the error log.
SetFilePointer (fileHandle, 0, 0, FILE_END);
// Print out some blank lines to separate this error log from any previous ones.
FPrintf (fileHandle, "Email Sonic Team Junior so we can fix the bugs\r\n"); // Tails
FPrintf (fileHandle, "Make sure you tell us what you were doing to cause the crash, and if possible, record a demo!\r\n"); // Tails
FPrintf (fileHandle, "\r\n\r\n\r\n\r\n");
FPrintf (fileHandle, "SRB2 %s -ERROR LOG-\r\n\r\n", VERSIONSTRING);
FPrintf (fileHandle, "\r\n");
// VirtualQuery can be used to get the allocation base associated with a
// code address, which is the same as the ModuleHandle. This can be used
// to get the filename of the module that the crash happened in.
if (VirtualQuery ((LPVOID)(size_t)Context->Eip, &MemInfo, sizeof (MemInfo)) &&
GetModuleFileName ((HMODULE)MemInfo.AllocationBase,
CrashModulePathName,
sizeof (CrashModulePathName)) > 0)
CrashModuleFileName = GetFilePart(CrashModulePathName);
// Print out the beginning of the error log in a Win95 error window
// compatible format.
FPrintf (fileHandle, "%s caused an %s in module %s at %04x:%08x.\r\n",
FileName, GetExceptionDescription(Exception->ExceptionCode),
CrashModuleFileName, Context->SegCs, Context->Eip);
//if (&Message = Null)
FPrintf (fileHandle, "Exception handler called in %s.\r\n", "main thread");
//else
//FPrintf (fileHandle, "Exception handler called in %s.\r\n", Message);
RecordSystemInformation (fileHandle);
// If the exception was an access violation, print out some additional
// information, to the error log and the debugger.
if (Exception->ExceptionCode == STATUS_ACCESS_VIOLATION &&
Exception->NumberParameters >= 2)
{
TCHAR DebugMessage[1000];
LPCTSTR readwrite = TEXT("Read from");
if (Exception->ExceptionInformation[0])
readwrite = TEXT("Write to");
wsprintf(DebugMessage, TEXT("%s location %08x caused an access violation.\r\n"),
readwrite, Exception->ExceptionInformation[1]);
#ifdef _DEBUG
// The VisualC++ debugger doesn't actually tell you whether a read
// or a write caused the access violation, nor does it tell what
// address was being read or written. So I fixed that.
OutputDebugString(TEXT("Exception handler: "));
OutputDebugString(DebugMessage);
#endif
FPrintf(fileHandle, "%s", DebugMessage);
}
FPrintf(fileHandle, "\r\n");
// Print out the register values in a Win95 error window compatible format.
if ((Context->ContextFlags & CONTEXT_FULL) == CONTEXT_FULL)
{
FPrintf (fileHandle, "Registers:\r\n");
FPrintf (fileHandle, "EAX=%.8lx CS=%.4x EIP=%.8lx EFLGS=%.8lx\r\n",
Context->Eax,Context->SegCs,Context->Eip,Context->EFlags);
FPrintf (fileHandle, "EBX=%.8lx SS=%.4x ESP=%.8lx EBP=%.8lx\r\n",
Context->Ebx,Context->SegSs,Context->Esp,Context->Ebp);
FPrintf (fileHandle, "ECX=%.8lx DS=%.4x ESI=%.8lx FS=%.4x\r\n",
Context->Ecx,Context->SegDs,Context->Esi,Context->SegFs);
FPrintf (fileHandle, "EDX=%.8lx ES=%.4x EDI=%.8lx GS=%.4x\r\n",
Context->Edx,Context->SegEs,Context->Edi,Context->SegGs);
}
// moved down because it was causing the printout to stop
FPrintf (fileHandle, "Command Line parameters: ");
for (i = 1;i < myargc;i++)
FPrintf (fileHandle, "%s ", myargv[i]);
FPrintf (fileHandle, "Bytes at CS : EIP:\r\n");
// Print out the bytes of code at the instruction pointer. Since the
// crash may have been caused by an instruction pointer that was bad,
// this code needs to be wrapped in an exception handler, in case there
// is no memory to read. If the dereferencing of code[] fails, the
// exception handler will print '??'.
code = (UINT8 *)(size_t)Context->Eip;
for (codebyte = 0; codebyte < NumCodeBytes; codebyte++)
{
#ifdef NO_SEH_MINGW
__try1(EXCEPTION_EXECUTE_HANDLER)
#else
__try
#endif
{
FPrintf (fileHandle, "%02x ", code[codebyte]);
}
#ifdef NO_SEH_MINGW
__except1
#else
__except(EXCEPTION_EXECUTE_HANDLER)
#endif
{
FPrintf (fileHandle, "?? ");
}
}
// Time to print part or all of the stack to the error log. This allows
// us to figure out the call stack, parameters, local variables, etc.
FPrintf (fileHandle, "\r\n"
"Stack dump:\r\n");
#ifdef NO_SEH_MINGW
__try1(EXCEPTION_EXECUTE_HANDLER)
#else
__try
#endif
{
// Esp contains the bottom of the stack, or at least the bottom of
// the currently used area.
DWORD* pStack = (DWORD *)(size_t)Context->Esp;
DWORD* pStackTop = NULL;
size_t Count = 0;
TCHAR buffer[1000] = TEXT("");
const int safetyzone = 50;
LPTSTR nearend = buffer + sizeof (buffer) - safetyzone*sizeof (TCHAR);
LPTSTR output = buffer;
const void *Suffix;
// Load the top (highest address) of the stack from the
// thread information block. It will be found there in
// Win9x and Windows NT.
#ifdef __GNUC__
__asm__("movl %%fs : 4, %%eax": "=a"(pStackTop));
#else
__asm
{
mov eax, fs:[4]
mov pStackTop, eax
}
#endif
if (pStackTop == NULL)
goto StackSkip;
else if (pStackTop > pStack + MaxStackDump)
pStackTop = pStack + MaxStackDump;
// Too many calls to WriteFile can take a long time, causing
// confusing delays when programs crash. Therefore I implemented
// simple buffering for the stack dumping code instead of calling
// FPrintf directly.
while (pStack + 1 <= pStackTop)
{
if ((Count % StackColumns) == 0)
output += wsprintf(output, TEXT("%08x: "), pStack);
if ((++Count % StackColumns) == 0 || pStack + 2 > pStackTop)
Suffix = TEXT("\r\n");
else
Suffix = TEXT(" ");
output += wsprintf(output, TEXT("%08x%s"), *pStack, Suffix);
pStack++;
// Check for when the buffer is almost full, and flush it to disk.
if (output > nearend)
{
FPrintf (fileHandle, "%s", buffer);
buffer[0] = 0;
output = buffer;
}
}
// Print out any final characters from the cache.
StackSkip:
FPrintf (fileHandle, "%s", buffer);
}
#ifdef NO_SEH_MINGW
__except1
#else
__except(EXCEPTION_EXECUTE_HANDLER)
#endif
{
FPrintf(fileHandle, "Exception encountered during stack dump.\r\n");
}
RecordModuleList (fileHandle);
CloseHandle (fileHandle);
// Return the magic value which tells Win32 that this handler didn't
// actually handle the exception - so that things will proceed as per
// normal.
//BP: should put message for end user to send this file to fix any bug
return EXCEPTION_CONTINUE_SEARCH;
}
/*
//
//FPrintf ("e-mail this file to legacy@newdoom.com, so that we can fix the problem.\r\n\r\n");
FPrintf ("Exception handler called in %s.\r\n", Message);
GetSystemTime (&systemTime);
FPrintf ("Error occured at %02d/%02d/%04d %02d:%02d:%02d.\r\n",
systemTime.wMonth, systemTime.wDay, systemTime.wYear,
systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
FPrintf ("%s\r\n", filename);
FPrintf ("Cmd-line: %s\r\n", lpCmdLine);
// Nested exceptions can occur, get info for each one
nER = 1;
while (ER)
{
if (nER++>1)
FPrintf ("Exception Record %d.\r\n", nER);
FPrintf ("application caused an %s", GetExceptionCodeStr(Exception->ExceptionCode));
if (Context->ContextFlags & CONTEXT_CONTROL)
FPrintf (" at %.4x:%.8x.\r\n", Context->SegCs, Context->Eip);
// in case of..
if (Context->Eip != (unsigned long)Exception->ExceptionAddress)
FPrintf ("Exception Address = %.8x\r\n", Exception->ExceptionAddress);
if (Exception->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
{
FPrintf ("\r\n%s location 0x%x caused an access violation.\r\n",
(Exception->ExceptionInformation[0] ? "Write to" : "Read from"),
Exception->ExceptionInformation[1]);
}
ER = Exception->ExceptionRecord;
}
if (Context->ContextFlags & CONTEXT_DEBUG_REGISTERS)
{
FPrintf ("\r\nDebug Registers:\r\n");
FPrintf ("Dr0=%.8x Dr1=%.8x Dr2=%.8x\r\n"
"Dr3=%.8x Dr6=%.8x Dr7=%.8x\r\n",
Context->Dr0, Context->Dr1, Context->Dr2,
Context->Dr3, Context->Dr6, Context->Dr7);
}
if (Context->ContextFlags & CONTEXT_FLOATING_POINT)
{
FPrintf ("\r\nFloating Save Area:\r\n");
FPrintf ("ControlWord =%.8x TagWord =%.8x ErrorSelector=%.8x DataSelector =%.8x\r\n"
"StatusWord =%.8x ErrorOffset =%.8x DataOffset =%.8x Cr0NpxState =%.8x\r\n",
Context->FloatSave.ControlWord, Context->FloatSave.TagWord, Context->FloatSave.ErrorSelector, Context->FloatSave.DataSelector,
Context->FloatSave.StatusWord, Context->FloatSave.ErrorOffset, Context->FloatSave.DataOffset, Context->FloatSave.Cr0NpxState
);
//BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
}
// in case of...
if ((Context->ContextFlags & CONTEXT_FULL) != CONTEXT_FULL)
{
if (!(Context->ContextFlags & CONTEXT_SEGMENTS))
FPrintf ("Note! GS,FS,ES,DS are unspecified\r\n");
if (!(Context->ContextFlags & CONTEXT_INTEGER))
FPrintf ("Note! EDI,ESI,EBX,EDX,ECX,EAX are unspecified\r\n");
if (!(Context->ContextFlags & CONTEXT_CONTROL))
FPrintf ("Note! EBP,CS : EIP,EFlags,SS : ESP are unspecified\r\n");
}
FPrintf ("\r\nBytes at CS : EIP:\r\n");
ucptr = (UINT8 *)Context->Eip;
for (i = 0; i < 16; i++)
FPrintf ("%.2x ", *ucptr++);
FPrintf ("\r\n\r\nStack dump:\r\n");
ulptr = (unsigned long*)Context->Esp;
for (i = 0; i < 16; i++)
FPrintf ("%.8x ", *ulptr++);
//FPrintf ("Bytes at CS : EIP:\r\n");
//FPrintf ("%.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x ");
for (i = 0; i < 16; i++)
{
FPrintf ("%x
}
*/

View file

@ -1,54 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief exception handler
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
// called in the exception filter of the __try block, writes all useful debugging information
// to a file, using only win32 functions in case the C runtime is in a bad state.
int __cdecl RecordExceptionInfo (PEXCEPTION_POINTERS data/*, LPCSTR Message, LPSTR lpCmdLine*/);
#ifdef __MINGW32__
#include <excpt.h>
#ifndef TRYLEVEL_NONE
#define NO_SEH_MINGW //Alam:?
FUNCINLINE static ATTRINLINE struct _EXCEPTION_POINTERS *GetExceptionInformation(VOID)
{
LPVOID SEHINFO = NULL;
//__asm__("movl -20(%%ebp), %%eax": "=a"(SEHINFO));
return SEHINFO;
}
//Alam_GBC: use __try1(seh)
#ifndef __try
#define __try
#endif //__try
//#undef NO_SEH_MINGW //Alam: win_dbg's code not working with MINGW
//Alam_GBC: use __except1
#ifndef __except
#define __except(x) if (0)
#endif //__except
#endif // !__TRYLEVEL_NONE
#endif // __MINGW32__

View file

@ -1,164 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief load and initialise the 3D driver DLL
#include "../doomdef.h"
#ifdef HWRENDER
#include "../hardware/hw_drv.h" // get the standard 3D Driver DLL exports prototypes
#endif
#ifdef HW3SOUND
#include "../hardware/hw3dsdrv.h" // get the 3D sound driver DLL export prototypes
#endif
#include "win_dll.h"
#include "win_main.h" // I_GetLastErrorMsgBox()
#if defined(HWRENDER) || defined(HW3SOUND)
typedef struct loadfunc_s {
LPCSTR fnName;
LPVOID fnPointer;
} loadfunc_t;
// --------------------------------------------------------------------------
// Load a DLL, returns the HMODULE handle or NULL
// --------------------------------------------------------------------------
static inline HMODULE LoadDLL (LPCSTR dllName, loadfunc_t *funcTable)
{
LPVOID funcPtr;
loadfunc_t *loadfunc;
HMODULE hModule;
if ((hModule = LoadLibraryA(dllName)) != NULL)
{
// get function pointers for all functions we use
for (loadfunc = funcTable; loadfunc->fnName != NULL; loadfunc++)
{
funcPtr = GetProcAddress(hModule, loadfunc->fnName);
if (!funcPtr) {
//I_GetLastErrorMsgBox ();
MessageBoxA(NULL, va("The '%s' haven't the good specification (function %s missing)\n\n"
"You must use dll from the same zip of this exe\n", dllName, loadfunc->fnName),
"Error", MB_OK|MB_ICONINFORMATION);
return FALSE;
}
// store function address
*((LPVOID*)loadfunc->fnPointer) = funcPtr;
}
}
else
{
MessageBoxA(NULL, va("LoadLibrary() FAILED : couldn't load '%s'\r\n", dllName), "Warning", MB_OK|MB_ICONINFORMATION);
//I_GetLastErrorMsgBox ();
}
return hModule;
}
// --------------------------------------------------------------------------
// Unload the DLL
// --------------------------------------------------------------------------
static inline VOID UnloadDLL (HMODULE* pModule)
{
if (FreeLibrary(*pModule))
*pModule = NULL;
else
I_GetLastErrorMsgBox ();
}
#endif
// ==========================================================================
// STANDARD 3D DRIVER DLL FOR DOOM LEGACY
// ==========================================================================
// note : the 3D driver loading should be put somewhere else..
#ifdef HWRENDER
static HMODULE hwdModule = NULL;
static loadfunc_t hwdFuncTable[] = {
{"_Init@4", &hwdriver.pfnInit},
{"_Shutdown@0", &hwdriver.pfnShutdown},
{"_GetModeList@8", &hwdriver.pfnGetModeList},
{"_SetPalette@8", &hwdriver.pfnSetPalette},
{"_FinishUpdate@4", &hwdriver.pfnFinishUpdate},
{"_Draw2DLine@12", &hwdriver.pfnDraw2DLine},
{"_DrawPolygon@16", &hwdriver.pfnDrawPolygon},
{"_SetBlend@4", &hwdriver.pfnSetBlend},
{"_ClearBuffer@12", &hwdriver.pfnClearBuffer},
{"_SetTexture@4", &hwdriver.pfnSetTexture},
{"_ReadRect@24", &hwdriver.pfnReadRect},
{"_GClipRect@20", &hwdriver.pfnGClipRect},
{"_ClearMipMapCache@0",&hwdriver.pfnClearMipMapCache},
{"_SetSpecialState@8", &hwdriver.pfnSetSpecialState},
{"_DrawMD2@16", &hwdriver.pfnDrawMD2},
{"_SetTransform@4", &hwdriver.pfnSetTransform},
{"_GetTextureUsed@0", &hwdriver.pfnGetTextureUsed},
{"_GetRenderVersion@0",&hwdriver.pfnGetRenderVersion},
{NULL,NULL}
};
BOOL Init3DDriver (LPCSTR dllName)
{
hwdModule = LoadDLL(dllName, hwdFuncTable);
return (hwdModule != NULL);
}
VOID Shutdown3DDriver (VOID)
{
UnloadDLL(&hwdModule);
}
#endif
#ifdef HW3SOUND
static HMODULE hwsModule = NULL;
static loadfunc_t hwsFuncTable[] = {
{"_Startup@8", &hw3ds_driver.pfnStartup},
{"_Shutdown@0", &hw3ds_driver.pfnShutdown},
{"_AddSfx@4", &hw3ds_driver.pfnAddSfx},
{"_AddSource@8", &hw3ds_driver.pfnAddSource},
{"_StartSource@4", &hw3ds_driver.pfnStartSource},
{"_StopSource@4", &hw3ds_driver.pfnStopSource},
{"_GetHW3DSVersion@0", &hw3ds_driver.pfnGetHW3DSVersion},
{"_BeginFrameUpdate@0", &hw3ds_driver.pfnBeginFrameUpdate},
{"_EndFrameUpdate@0", &hw3ds_driver.pfnEndFrameUpdate},
{"_IsPlaying@4", &hw3ds_driver.pfnIsPlaying},
{"_UpdateListener@8", &hw3ds_driver.pfnUpdateListener},
{"_UpdateSourceParms@12", &hw3ds_driver.pfnUpdateSourceParms},
{"_SetCone@8", &hw3ds_driver.pfnSetCone},
{"_SetGlobalSfxVolume@4", &hw3ds_driver.pfnSetGlobalSfxVolume},
{"_Update3DSource@8", &hw3ds_driver.pfnUpdate3DSource},
{"_ReloadSource@8", &hw3ds_driver.pfnReloadSource},
{"_KillSource@4", &hw3ds_driver.pfnKillSource},
{"_KillSfx@4", &hw3ds_driver.pfnKillSfx},
{"_GetHW3DSTitle@8", &hw3ds_driver.pfnGetHW3DSTitle},
{NULL, NULL}
};
BOOL Init3DSDriver(LPCSTR dllName)
{
hwsModule = LoadDLL(dllName, hwsFuncTable);
return (hwsModule != NULL);
}
VOID Shutdown3DSDriver (VOID)
{
UnloadDLL(&hwsModule);
}
#endif

View file

@ -1,31 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief load/unload a DLL at run-time
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
#ifdef HWRENDER
BOOL Init3DDriver (LPCSTR dllName);
VOID Shutdown3DDriver (VOID);
#endif
#ifdef HW3SOUND
BOOL Init3DSDriver(LPCSTR dllName);
VOID Shutdown3DSDriver(VOID);
#endif

View file

@ -1,123 +0,0 @@
#include <stdlib.h>
#include <windows.h>
#include "win_file.h"
int FileAccess(LPCTSTR FileName, DWORD mode)
{
HANDLE hFile;
hFile = CreateFile( FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if (hFile == INVALID_HANDLE_VALUE)
return -1;
else
{
FileClose(hFile);
return 0;
}
}
HANDLE FileCreate(LPCTSTR FileName)
{
HANDLE hFile;
if (FileAccess( FileName, 0) == 0)
hFile = CreateFile( FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
else
hFile = CreateFile( FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
return hFile;
}
void FileClose(HANDLE hFile)
{
CloseHandle(hFile);
}
DWORD FileLength(HANDLE hFile)
{
return GetFileSize(hFile, NULL);
}
HANDLE FileOpen(LPCTSTR FileName)
{
HANDLE hFile;
hFile = CreateFile( FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
return hFile;
}
HANDLE FileAppend(LPCTSTR FileName)
{
HANDLE hFile;
hFile = CreateFile( FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
FileSeek(hFile, 0, FILE_END );
return hFile;
}
DWORD FileRead(HANDLE hFile, LPVOID data, DWORD size)
{
DWORD readin = 0;
ReadFile(hFile, data, size, &readin, NULL);
return readin;
}
DWORD FileSeek(HANDLE hFile, LONG distance, DWORD method)
{
DWORD position;
position = SetFilePointer(hFile, distance, NULL, method);
return position;
}
DWORD FileWrite(HANDLE hFile, LPCVOID data, DWORD size)
{
DWORD written = 0;
WriteFile(hFile, data, size, &written, NULL);
return written;
}
//These functions are provided as CRT replacements. (missing from WinCE)
int access(char* file,int type)
{
FILE* file_access = 0;
file_access = fopen(file,"rb");
if(file_access)
{
fclose(file_access);
return 0;
}
return -1;
}
unsigned int file_len(char* file)
{
FILE* file_access;
unsigned int len = 0;
file_access = fopen(file,"rb");
if(!file_access)
return 0;
fseek(file_access,0,SEEK_END);
len = ftell(file_access);
fclose(file_access);
return len;
}

View file

@ -1,19 +0,0 @@
#ifndef FILE_H
#define FILE_H
// New File I/O functions
int FileAccess(LPCTSTR, DWORD);
HANDLE FileAppend(LPCTSTR FileName);
void FileClose(HANDLE);
HANDLE FileCreate(LPCTSTR);
DWORD FileLength(HANDLE);
HANDLE FileOpen(LPCTSTR);
DWORD FileRead(HANDLE, LPCVOID, DWORD);
DWORD FileSeek(HANDLE hFile, LONG distance, DWORD method);
DWORD FileWrite(HANDLE, LPCVOID, DWORD);
int access(char* file,int type);
unsigned int file_len(char* file);
#endif

View file

@ -1,539 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief Win32 WinMain Entry Point
///
/// Win32 Sonic Robo Blast 2
///
/// NOTE:
/// To compile WINDOWS SRB2 version : define a '_WINDOWS' symbol.
/// to do this go to Project/Settings/ menu, click C/C++ tab, in
/// 'Preprocessor definitions:' add '_WINDOWS'
#include "../doomdef.h"
#include <stdio.h>
#include "../doomstat.h" // netgame
#include "resource.h"
#include "../m_argv.h"
#include "../d_main.h"
#include "../i_system.h"
#include "../keys.h" //hack quick test
#include "../console.h"
#include "fabdxlib.h"
#include "win_main.h"
#include "win_dbg.h"
#include "../i_sound.h" // midi pause/unpause
#include "../g_input.h" // KEY_MOUSEWHEELxxx
// MSWheel support for Win95/NT3.51
#include <zmouse.h>
#ifndef WM_XBUTTONDOWN
#define WM_XBUTTONDOWN 523
#endif
#ifndef WM_XBUTTONUP
#define WM_XBUTTONUP 524
#endif
#ifndef MK_XBUTTON1
#define MK_XBUTTON1 32
#endif
#ifndef MK_XBUTTON2
#define MK_XBUTTON2 64
#endif
typedef BOOL (WINAPI *MyFunc)(VOID);
HINSTANCE myInstance = NULL;
HWND hWndMain = NULL;
static HCURSOR windowCursor = NULL; // main window cursor
boolean appActive = false; // app window is active
#ifdef LOGMESSAGES
// this is were I log debug text, cons_printf, I_error ect for window port debugging
HANDLE logstream;
#endif
BOOL nodinput = FALSE;
static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
event_t ev; //Doom input event
int mouse_keys;
// judgecutor:
// Response MSH Mouse Wheel event
if (message == MSHWheelMessage)
{
message = WM_MOUSEWHEEL;
if (win9x)
wParam <<= 16;
}
switch (message)
{
case WM_CREATE:
nodinput = M_CheckParm("-nodinput");
break;
case WM_ACTIVATEAPP: // Handle task switching
appActive = (int)wParam;
// pause music when alt-tab
if (appActive && !paused)
I_ResumeSong(0);
else if (!paused)
I_PauseSong(0);
{
HANDLE ci = GetStdHandle(STD_INPUT_HANDLE);
if (ci != INVALID_HANDLE_VALUE && GetFileType(ci) == FILE_TYPE_CHAR)
appActive = true;
}
InvalidateRect (hWnd, NULL, TRUE);
break;
//for MIDI music
case WM_MSTREAM_UPDATEVOLUME:
I_SetMidiChannelVolume((DWORD)wParam, dwVolumePercent);
break;
case WM_PAINT:
if (!appActive && !bAppFullScreen && !netgame)
// app becomes inactive (if windowed)
{
// Paint "Game Paused" in the middle of the screen
PAINTSTRUCT ps;
RECT rect;
HDC hdc = BeginPaint (hWnd, &ps);
GetClientRect (hWnd, &rect);
DrawText (hdc, TEXT("Game Paused"), -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint (hWnd, &ps);
return 0;
}
break;
//case WM_RBUTTONDOWN:
//case WM_LBUTTONDOWN:
case WM_MOVE:
if (bAppFullScreen)
{
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
return 0;
}
else
{
windowPosX = (SHORT) LOWORD(lParam); // horizontal position
windowPosY = (SHORT) HIWORD(lParam); // vertical position
break;
}
break;
// This is where switching windowed/fullscreen is handled. DirectDraw
// objects must be destroyed, recreated, and artwork reloaded.
case WM_DISPLAYCHANGE:
case WM_SIZE:
break;
case WM_SETCURSOR:
if (bAppFullScreen)
SetCursor(NULL);
else
SetCursor(windowCursor);
return TRUE;
case WM_KEYUP:
ev.type = ev_keyup;
goto handleKeyDoom;
break;
case WM_KEYDOWN:
ev.type = ev_keydown;
handleKeyDoom:
ev.data1 = 0;
if (wParam == VK_PAUSE)
// intercept PAUSE key
{
ev.data1 = KEY_PAUSE;
}
else if (!keyboard_started)
// post some keys during the game startup
// (allow escaping from network synchronization, or pressing enter after
// an error message in the console)
{
switch (wParam)
{
case VK_ESCAPE: ev.data1 = KEY_ESCAPE; break;
case VK_RETURN: ev.data1 = KEY_ENTER; break;
default: ev.data1 = MapVirtualKey((DWORD)wParam,2); // convert in to char
}
}
if (ev.data1)
D_PostEvent (&ev);
return 0;
break;
// judgecutor:
// Handle mouse events
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
case WM_MOUSEMOVE:
if (nodinput)
{
mouse_keys = 0;
if (wParam & MK_LBUTTON)
mouse_keys |= 1;
if (wParam & MK_RBUTTON)
mouse_keys |= 2;
if (wParam & MK_MBUTTON)
mouse_keys |= 4;
if (wParam & MK_XBUTTON1)
mouse_keys |= 8;
if (wParam & MK_XBUTTON2)
mouse_keys |= 16;
I_GetSysMouseEvents(mouse_keys);
}
break;
case WM_MOUSEWHEEL:
//CONS_Printf("MW_WHEEL dispatched.\n");
ev.type = ev_keydown;
if ((INT16)HIWORD(wParam) > 0)
ev.data1 = KEY_MOUSEWHEELUP;
else
ev.data1 = KEY_MOUSEWHEELDOWN;
D_PostEvent(&ev);
break;
case WM_SETTEXT:
COM_BufAddText((LPCSTR)lParam);
return TRUE;
break;
case WM_CLOSE:
PostQuitMessage(0); //to quit while in-game
ev.data1 = KEY_ESCAPE; //to exit network synchronization
ev.type = ev_keydown;
D_PostEvent (&ev);
return 0;
case WM_DESTROY:
//faB: main app loop will exit the loop and proceed with I_Quit()
PostQuitMessage(0);
break;
default:
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
static inline VOID OpenTextConsole(void)
{
HANDLE ci, co;
const BOOL tco = M_CheckParm("-console") != 0;
dedicated = M_CheckParm("-dedicated") != 0;
if (!(dedicated || tco))
return;
FreeConsole();
AllocConsole(); //Let get the real console HANDLE, because Mingw's Bash is bad!
ci = CreateFile(TEXT("CONIN$") , GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
co = CreateFile(TEXT("CONOUT$"), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (ci != (HANDLE)-1)
{
const DWORD CM = ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_PROCESSED_INPUT;
SetStdHandle(STD_INPUT_HANDLE,ci);
if(GetFileType(ci) == FILE_TYPE_CHAR)
SetConsoleMode(ci,CM); //default mode but no ENABLE_MOUSE_INPUT
}
if(co != (HANDLE)-1)
{
SetStdHandle(STD_OUTPUT_HANDLE,co);
SetStdHandle(STD_ERROR_HANDLE,co); //maybe logstream?
}
}
//
// Do that Windows initialization stuff...
//
static HWND OpenMainWindow (HINSTANCE hInstance, int nCmdShow, LPSTR wTitle)
{
HWND hWnd;
WNDCLASS wc;
// Set up and register window class
nCmdShow = 0;
wc.style = CS_HREDRAW | CS_VREDRAW /*| CS_DBLCLKS*/;
wc.lpfnWndProc = MainWndproc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DLICON1));
windowCursor = LoadCursor(NULL, IDC_WAIT); //LoadCursor(hInstance, MAKEINTRESOURCE(IDC_DLCURSOR1));
wc.hCursor = windowCursor;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = TEXT("SRB2WC");
if (!RegisterClass(&wc))
return (HANDLE)-1;
// Create a window
// CreateWindowEx - seems to create just the interior, not the borders
hWnd = CreateWindowExA(
#ifdef _DEBUG
0, //ExStyle
#else
dedicated ? 0:WS_EX_TOPMOST, //ExStyle
#endif
"SRB2WC", //Classname
wTitle, //Windowname
WS_CAPTION|WS_POPUP|WS_SYSMENU, //dwStyle //WS_VISIBLE|WS_POPUP for bAppFullScreen
0,
0,
dedicated ? 0:BASEVIDWIDTH, //GetSystemMetrics(SM_CXSCREEN),
dedicated ? 0:BASEVIDHEIGHT, //GetSystemMetrics(SM_CYSCREEN),
NULL, //hWnd Parent
NULL, //hMenu Menu
hInstance,
NULL);
return hWnd;
}
static inline BOOL tlErrorMessage(const TCHAR *err)
{
/* make the cursor visible */
SetCursor(LoadCursor(NULL, IDC_ARROW));
//
// warn user if there is one
//
printf("Error %s..\n", err);
fflush(stdout);
MessageBox(hWndMain, err, TEXT("ERROR"), MB_OK);
return FALSE;
}
// ------------------
// Command line stuff
// ------------------
#define MAXCMDLINEARGS 64
static char * myWargv[MAXCMDLINEARGS+1];
static char myCmdline[512];
static VOID GetArgcArgv (LPSTR cmdline)
{
LPSTR token;
size_t i = 0, len;
char cSep = ' ';
BOOL bCvar = FALSE, prevCvar = FALSE;
// split arguments of command line into argv
strncpy (myCmdline, cmdline, 511); // in case window's cmdline is in protected memory..for strtok
len = strlen (myCmdline);
myargc = 0;
while (myargc < MAXCMDLINEARGS)
{
// get token
while (myCmdline[i] == cSep)
i++;
if (i >= len)
break;
token = myCmdline + i;
if (myCmdline[i] == '"')
{
cSep = '"';
i++;
if (!prevCvar) //cvar leave the "" in
token++;
}
else
cSep = ' ';
//cvar
if (myCmdline[i] == '+' && cSep == ' ') //a + begins a cvarname, but not after quotes
bCvar = TRUE;
else
bCvar = FALSE;
while (myCmdline[i] &&
myCmdline[i] != cSep)
i++;
if (myCmdline[i] == '"')
{
cSep = ' ';
if (prevCvar)
i++; // get ending " quote in arg
}
prevCvar = bCvar;
if (myCmdline + i > token)
{
myWargv[myargc++] = token;
}
if (!myCmdline[i] || i >= len)
break;
myCmdline[i++] = '\0';
}
myWargv[myargc] = NULL;
// m_argv.c uses myargv[], we used myWargv because we fill the arguments ourselves
// and myargv is just a pointer, so we set it to point myWargv
myargv = myWargv;
}
static inline VOID MakeCodeWritable(VOID)
{
#ifdef USEASM
// Disable write-protection of code segment
DWORD OldRights;
BYTE *pBaseOfImage = (BYTE *)GetModuleHandle(NULL);
IMAGE_OPTIONAL_HEADER *pHeader = (IMAGE_OPTIONAL_HEADER *)
(pBaseOfImage + ((IMAGE_DOS_HEADER*)pBaseOfImage)->e_lfanew +
sizeof (IMAGE_NT_SIGNATURE) + sizeof (IMAGE_FILE_HEADER));
if (!VirtualProtect(pBaseOfImage+pHeader->BaseOfCode,pHeader->SizeOfCode,PAGE_EXECUTE_READWRITE,&OldRights))
I_Error("Could not make code writable\n");
#endif
}
// -----------------------------------------------------------------------------
// HandledWinMain : called by exception handler
// -----------------------------------------------------------------------------
static int WINAPI HandledWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int i;
LPSTR args;
lpCmdLine = NULL;
hPrevInstance = NULL;
#ifdef LOGMESSAGES
// DEBUG!!! - set logstream to NULL to disable debug log
logstream = INVALID_HANDLE_VALUE;
logstream = CreateFile (TEXT("log.txt"), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL); //file flag writethrough?
#endif
// fill myargc,myargv for m_argv.c retrieval of cmdline arguments
CONS_Printf("GetArgcArgv() ...\n");
args = GetCommandLineA();
CONS_Printf("lpCmdLine is '%s'\n", args);
GetArgcArgv(args);
// Create a text console window
OpenTextConsole();
CONS_Printf("Myargc: %d\n", myargc);
for (i = 0; i < myargc; i++)
CONS_Printf("myargv[%d] : '%s'\n", i, myargv[i]);
// store for later use, will we need it ?
myInstance = hInstance;
// open a dummy window, both OpenGL and DirectX need one.
if ((hWndMain = OpenMainWindow(hInstance,nCmdShow,
va("SRB2 "VERSIONSTRING))) == (HANDLE)-1)
{
tlErrorMessage(TEXT("Couldn't open window"));
return FALSE;
}
// currently starts DirectInput
CONS_Printf("I_StartupSystem() ...\n");
I_StartupSystem();
MakeCodeWritable();
// startup SRB2
CONS_Printf("D_SRB2Main() ...\n");
D_SRB2Main();
CONS_Printf("Entering main app loop...\n");
// never return
D_SRB2Loop();
// back to Windoze
return 0;
}
// -----------------------------------------------------------------------------
// Exception handler calls WinMain for catching exceptions
// -----------------------------------------------------------------------------
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
int Result = -1;
#if 1
HMODULE h = GetModuleHandleA("kernel32.dll");
MyFunc pfnIsDebuggerPresent = NULL;
if (h)
pfnIsDebuggerPresent = (MyFunc)GetProcAddress(h,"IsDebuggerPresent");
if (!pfnIsDebuggerPresent || !pfnIsDebuggerPresent())
LoadLibrary("exchndl.dll");
#endif
#ifdef NO_SEH_MINGW
__try1(RecordExceptionInfo(GetExceptionInformation()/*, "main thread", lpCmdLine*/))
#else
__try
#endif
{
Result = HandledWinMain (hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
#ifdef NO_SEH_MINGW
__except1
#else
__except (RecordExceptionInfo(GetExceptionInformation()/*, "main thread", lpCmdLine*/))
#endif
{
SetUnhandledExceptionFilter(EXCEPTION_CONTINUE_SEARCH); //Do nothing here.
}
return Result;
}

View file

@ -1,55 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief Win32 Sharing
//#define WIN32_LEAN_AND_MEAN
#define RPC_NO_WINDOWS_H
#include <windows.h>
#include <stdio.h>
extern HINSTANCE myInstance;
extern HWND hWndMain;
// debugging CONS_Printf to file
#ifdef LOGMESSAGES
extern HANDLE logstream;
#endif
extern int appActive;
// the MIDI callback is another thread, and Midi volume is delayed here in window proc
VOID I_SetMidiChannelVolume(DWORD dwChannel, DWORD dwVolumePercent);
extern DWORD dwVolumePercent;
VOID I_GetSysMouseEvents(int mouse_state);
extern unsigned int MSHWheelMessage;
extern BOOL nodinput;
extern BOOL win9x;
//faB: midi channel Volume set is delayed by the MIDI stream callback thread, see win_snd.c
#define WM_MSTREAM_UPDATEVOLUME (WM_USER + 101)
// defined in win_sys.c
VOID I_BeginProfile(VOID); //for timing code
DWORD I_EndProfile(VOID);
VOID I_GetLastErrorMsgBox(VOID);
VOID I_LoadingScreen (LPCSTR msg);
void I_RestartSysMouse(void);
void I_DoStartupMouse(void);
BOOL I_SaveMemToFile(const void *pData, size_t iLength, const char *sFileName);

View file

@ -1,39 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief Win32 network interface
#include "../doomdef.h"
#include "../m_argv.h"
#include "../i_net.h"
//
// NETWORKING
//
//
// I_InitNetwork
//
boolean I_InitNetwork (void)
{
if (M_CheckParm ("-net"))
{
I_Error("The Win32 version of SRB2 doesn't work with external drivers like ipxsetup, sersetup, or doomatic\n"
"Read the documentation about \"-server\" and \"-connect\" parameters or just use the launcher\n");
}
return false;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,865 +0,0 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright (C) 1998-2000 by DooM Legacy Team.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//-----------------------------------------------------------------------------
/// \file
/// \brief win32 video driver for Doom Legacy
#include "../doomdef.h"
#include <stdlib.h>
#include <stdarg.h>
#include "../d_clisrv.h"
#include "../i_system.h"
#include "../m_argv.h"
#include "../v_video.h"
#include "../st_stuff.h"
#include "../i_video.h"
#include "../z_zone.h"
#include "fabdxlib.h"
#include "win_main.h"
#include "../command.h"
#include "../screen.h"
#ifdef HWRENDER
#include "win_dll.h" // loading the render DLL
#include "../hardware/hw_drv.h" // calling driver init & shutdown
#include "../hardware/hw_main.h" // calling HWR module init & shutdown
#endif
// -------
// Globals
// -------
// this is the CURRENT rendermode!! very important: used by w_wad, and much other code
rendermode_t rendermode = render_soft;
// synchronize page flipping with screen refresh
consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static consvar_t cv_stretch = {"stretch", "On", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
boolean highcolor;
static BOOL bDIBMode; // means we are using DIB instead of DirectDraw surfaces
static BITMAPINFO* bmiMain = NULL;
static HDC hDCMain = NULL;
// -----------------
// Video modes stuff
// -----------------
#define MAX_EXTRA_MODES 36
static vmode_t extra_modes[MAX_EXTRA_MODES] = {{NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0}};
static char names[MAX_EXTRA_MODES][10];
static int numvidmodes; // total number of DirectDraw display modes
static vmode_t *pvidmodes; // start of videomodes list.
static vmode_t *pcurrentmode; // the current active videomode.
static BOOL bWinParm;
static int WINAPI VID_SetWindowedDisplayMode(viddef_t *lvid, vmode_t *pcurrentmode);
// this holds description of the startup video mode,
// the resolution is 320x200, windowed on the desktop
#define NUMSPECIALMODES 1
static char winmode1[] ="320x200W"; // W to make sure it's the windowed mode
static vmode_t specialmodes[NUMSPECIALMODES] =
{
{
NULL,
winmode1, // hehe
320, 200, //(200.0/320.0)*(320.0/240.0),
320, 1, // rowbytes, bytes per pixel
1, 2, // windowed (TRUE), numpages
NULL,
VID_SetWindowedDisplayMode, 0
}
};
// ------
// Protos
// ------
static void VID_Command_NumModes_f(void);
static void VID_Command_ModeInfo_f(void);
static void VID_Command_ModeList_f(void);
static void VID_Command_Mode_f(void);
static int WINAPI VID_SetDirectDrawMode(viddef_t *lvid, vmode_t *pcurrentmode);
static vmode_t *VID_GetModePtr(int modenum);
static void VID_Init(void);
static BOOL VID_FreeAndAllocVidbuffer(viddef_t *lvid);
// -----------------
// I_StartupGraphics
// Initialize video mode, setup dynamic screen size variables,
// and allocate screens.
// -----------------
void I_StartupGraphics(void)
{
if (graphics_started)
return;
#ifdef HWRENDER
if (M_CheckParm("-opengl"))
rendermode = render_opengl;
else
rendermode = render_soft;
#endif
if (dedicated)
rendermode = render_none;
else
VID_Init();
// register exit code for graphics
I_AddExitFunc(I_ShutdownGraphics);
if (!dedicated) graphics_started = true;
}
// ------------------
// I_ShutdownGraphics
// Close the screen, restore previous video mode.
// ------------------
void I_ShutdownGraphics(void)
{
if (!graphics_started)
return;
CONS_Printf("I_ShutdownGraphics()\n");
//FreeConsole();
// release windowed startup stuff
if (hDCMain)
{
ReleaseDC(hWndMain, hDCMain);
hDCMain = NULL;
}
if (bmiMain)
{
GlobalFree(bmiMain);
bmiMain = NULL;
}
#ifdef HWRENDER
if (rendermode != render_soft)
{
HWR_Shutdown(); // free stuff from the hardware renderer
HWD.pfnShutdown(); // close 3d card display
Shutdown3DDriver(); // free the driver DLL
}
#endif
// free the last video mode screen buffers
if (vid.buffer)
{
GlobalFree(vid.buffer);
vid.buffer = NULL;
}
#ifdef HWRENDER
if (rendermode == render_soft)
#endif
CloseDirectDraw();
graphics_started = false;
}
// --------------
// I_UpdateNoBlit
// --------------
void I_UpdateNoBlit(void)
{
// what is this?
}
// --------------
// I_FinishUpdate
// --------------
void I_FinishUpdate(void)
{
int i;
if (rendermode == render_none)
return;
// draw captions if enabled
if (cv_closedcaptioning.value)
SCR_ClosedCaptions();
// display a graph of ticrate
if (cv_ticrate.value)
SCR_DisplayTicRate();
//
if (bDIBMode)
{
// paranoia
if (!hDCMain || !bmiMain || !vid.buffer)
return;
// main game loop, still in a window (-win parm)
SetDIBitsToDevice(hDCMain, 0, 0, 320, 200, 0, 0, 0, 200, vid.buffer, bmiMain,
DIB_RGB_COLORS);
}
else
#ifdef HWRENDER
if (rendermode != render_soft)
HWD.pfnFinishUpdate(cv_vidwait.value);
else
#endif
{
// DIRECT DRAW
// copy virtual screen to real screen
// can fail when not active (alt-tab)
if (LockScreen())
{
/// \todo use directX blit here!!? a blit might use hardware with access
/// to main memory on recent hardware, and software blit of directX may be
/// optimized for p2 or mmx??
VID_BlitLinearScreen(screens[0], ScreenPtr, vid.width*vid.bpp, vid.height,
vid.width*vid.bpp, ScreenPitch);
UnlockScreen();
// swap screens
ScreenFlip(cv_vidwait.value);
}
}
}
//
// This is meant to be called only by CONS_Printf() while game startup
//
void I_LoadingScreen(LPCSTR msg)
{
RECT rect;
// paranoia
if (!hDCMain || !bmiMain || !vid.buffer)
return;
GetClientRect(vid.WndParent, &rect);
SetDIBitsToDevice(hDCMain, 0, 0, 320, 200, 0, 0, 0, 200, vid.buffer, bmiMain, DIB_RGB_COLORS);
if (msg)
{
if (rect.bottom - rect.top > 32)
rect.top = rect.bottom - 32; // put msg on bottom of window
SetBkMode(hDCMain, TRANSPARENT);
SetTextColor(hDCMain, RGB(0x00, 0x00, 0x00));
DrawTextA(hDCMain, msg, -1, &rect, DT_WORDBREAK|DT_CENTER);
}
}
// ------------
// I_ReadScreen
// ------------
void I_ReadScreen(UINT8 *scr)
{
// DEBUGGING
if (rendermode != render_soft)
I_Error("I_ReadScreen: called while in non-software mode");
VID_BlitLinearScreen(screens[0], scr, vid.width*vid.bpp, vid.height, vid.width*vid.bpp,
vid.rowbytes);
}
// ------------
// I_SetPalette
// ------------
void I_SetPalette(RGBA_t *palette)
{
int i;
if (bDIBMode)
{
// set palette in RGBQUAD format, NOT THE SAME ORDER as PALETTEENTRY, grmpf!
RGBQUAD *pColors;
pColors = (RGBQUAD *)((char *)bmiMain + bmiMain->bmiHeader.biSize);
ZeroMemory(pColors, sizeof (RGBQUAD)*256);
for (i = 0; i < 256; i++, pColors++, palette++)
{
pColors->rgbRed = palette->s.red;
pColors->rgbGreen = palette->s.green;
pColors->rgbBlue = palette->s.blue;
}
}
else
#ifdef HWRENDER
if (rendermode == render_soft)
#endif
{
PALETTEENTRY mainpal[256];
// this clears the 'flag' for each color in palette
ZeroMemory(mainpal, sizeof mainpal);
// set palette in PALETTEENTRY format
for (i = 0; i < 256; i++, palette++)
{
mainpal[i].peRed = palette->s.red;
mainpal[i].peGreen = palette->s.green;
mainpal[i].peBlue = palette->s.blue;
}
SetDDPalette(mainpal); // set DirectDraw palette
}
}
//
// return number of video modes in pvidmodes list
//
INT32 VID_NumModes(void)
{
return numvidmodes - NUMSPECIALMODES; //faB: dont accept the windowed mode 0
}
// return a video mode number from the dimensions
// returns any available video mode if the mode was not found
INT32 VID_GetModeForSize(INT32 w, INT32 h)
{
vmode_t *pv = pvidmodes;
int modenum = 0;
// skip the special modes so that it finds only fullscreen modes
for (; pv && modenum < NUMSPECIALMODES; pv = pv->pnext, ++modenum);
for (; pv; pv = pv->pnext, ++modenum)
if (pv->width == (unsigned)w && pv->height == (unsigned)h)
return modenum;
// if not found, return the first mode available,
// preferably a full screen mode (all modes after the 'specialmodes')
if (numvidmodes > NUMSPECIALMODES)
return NUMSPECIALMODES; // use first full screen mode
return 0; // no fullscreen mode, use windowed mode
}
//
// Enumerate DirectDraw modes available
//
static int nummodes = 0;
static BOOL GetExtraModesCallback(int width, int height, int bpp)
{
CONS_Printf("mode %d x %d x %d bpp\n", width, height, bpp);
// skip all unwanted modes
if (highcolor && bpp != 15)
goto skip;
if (!highcolor && bpp != 8)
goto skip;
if (bpp > 16 || width > MAXVIDWIDTH || height > MAXVIDHEIGHT)
goto skip;
// check if we have space for this mode
if (nummodes >= MAX_EXTRA_MODES)
{
CONS_Printf("mode skipped (too many)\n");
return FALSE;
}
// store mode info
extra_modes[nummodes].pnext = &extra_modes[nummodes+1];
memset(names[nummodes], 0, 10);
snprintf(names[nummodes], 9, "%dx%d", width, height);
extra_modes[nummodes].name = names[nummodes];
extra_modes[nummodes].width = width;
extra_modes[nummodes].height = height;
// exactly, the current FinishUdpate() gets the rowbytes itself after locking the video buffer
// so for now we put anything here
extra_modes[nummodes].rowbytes = width;
extra_modes[nummodes].windowed = false;
extra_modes[nummodes].misc = 0; // unused
extra_modes[nummodes].pextradata = NULL;
extra_modes[nummodes].setmode = VID_SetDirectDrawMode;
extra_modes[nummodes].numpages = 2; // double-buffer (but this value is unused)
extra_modes[nummodes].bytesperpixel = (bpp+1)>>3;
nummodes++;
skip:
return TRUE;
}
//
// Collect info about DirectDraw display modes we use
//
static inline void VID_GetExtraModes(void)
{
nummodes = 0;
EnumDirectDrawDisplayModes(GetExtraModesCallback);
// add the extra modes (not 320x200) at the start of the mode list (if there are any)
if (nummodes)
{
extra_modes[nummodes-1].pnext = NULL;
pvidmodes = &extra_modes[0];
numvidmodes += nummodes;
}
}
// ---------------
// WindowMode_Init
// Add windowed modes to the start of the list,
// mode 0 is used for windowed console startup (works on all computers with no DirectX)
// ---------------
static void WindowMode_Init(void)
{
specialmodes[NUMSPECIALMODES-1].pnext = pvidmodes;
pvidmodes = &specialmodes[0];
numvidmodes += NUMSPECIALMODES;
}
// *************************************************************************************
// VID_Init
// Initialize Video modes subsystem
// *************************************************************************************
static void VID_Init(void)
{
vmode_t *pv;
int iMode;
// if '-win' is specified on the command line, do not add DirectDraw modes
bWinParm = M_CheckParm("-win");
COM_AddCommand("vid_nummodes", VID_Command_NumModes_f);
COM_AddCommand("vid_modeinfo", VID_Command_ModeInfo_f);
COM_AddCommand("vid_modelist", VID_Command_ModeList_f);
COM_AddCommand("vid_mode", VID_Command_Mode_f);
CV_RegisterVar(&cv_vidwait);
CV_RegisterVar(&cv_stretch);
// setup the videmodes list,
// note that mode 0 must always be VGA mode 0x13
pvidmodes = pcurrentmode = NULL;
numvidmodes = 0;
// store the main window handle in viddef struct
SetWindowPos(hWndMain, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_NOMOVE);
vid.WndParent = hWndMain;
vid.buffer = NULL;
// we startup in windowed mode using DIB bitmap
// we will use DirectDraw when switching fullScreen and entering main game loop
bDIBMode = TRUE;
bAppFullScreen = FALSE;
#ifdef HWRENDER
// initialize the appropriate display device
if (rendermode != render_soft)
{
const char *drvname = NULL;
switch (rendermode)
{
case render_opengl:
drvname = "r_opengl.dll";
break;
default:
I_Error("Unknown hardware render mode");
}
// load the DLL
if (drvname && Init3DDriver(drvname))
{
int hwdversion = HWD.pfnGetRenderVersion();
if (hwdversion != VERSION)
CONS_Printf("WARNING: This r_opengl version is not supported, use it at your own risk.\n");
// perform initialisations
HWD.pfnInit(I_Error);
// get available display modes for the device
HWD.pfnGetModeList(&pvidmodes, &numvidmodes);
}
else
{
switch (rendermode)
{
case render_opengl:
I_Error("Error initializing OpenGL");
default:
break;
}
rendermode = render_soft;
}
}
if (rendermode == render_soft)
#endif
if (!bWinParm)
{
if (!CreateDirectDrawInstance())
I_Error("Error initializing DirectDraw");
// get available display modes for the device
VID_GetExtraModes();
}
// the game boots in 320x200 standard VGA, but
// we need a highcolor mode to run the game in highcolor
if (highcolor && !numvidmodes)
I_Error("Cannot run in highcolor - No 15bit highcolor DirectX video mode found.");
// add windowed mode at the start of the list, very important!
WindowMode_Init();
if (!numvidmodes)
I_Error("No display modes available.");
// DEBUG
for (iMode = 0, pv = pvidmodes; pv; pv = pv->pnext, iMode++)
CONS_Printf("#%02d: %dx%dx%dbpp (desc: '%s')\n", iMode, pv->width, pv->height,
pv->bytesperpixel, pv->name);
// set the startup screen in a window
VID_SetMode(0);
}
// --------------------------
// VID_SetWindowedDisplayMode
// Display the startup 320x200 console screen into a window on the desktop,
// switching to fullscreen display only when we will enter the main game loop.
// - we can display error message boxes for startup errors
// - we can set the last used resolution only once, when entering the main game loop
// --------------------------
static int WINAPI VID_SetWindowedDisplayMode(viddef_t *lvid, vmode_t *pcurrentmode)
{
int iScrWidth, iScrHeight, iWinWidth, iWinHeight;
pcurrentmode = NULL;
#ifdef DEBUG
CONS_Printf("VID_SetWindowedDisplayMode()\n");
#endif
lvid->u.numpages = 1; // not used
lvid->direct = NULL; // DOS remains
lvid->buffer = NULL;
// allocate screens
if (!VID_FreeAndAllocVidbuffer(lvid))
return -1;
// lvid->buffer should be NULL here!
bmiMain = (void *)GlobalAlloc(GPTR, sizeof (BITMAPINFO) + (sizeof (RGBQUAD)*256));
if (!bmiMain)
I_Error("VID_SWDM(): No mem");
// setup a BITMAPINFO to allow copying our video buffer to the desktop,
// with color conversion as needed
bmiMain->bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
bmiMain->bmiHeader.biWidth = lvid->width;
bmiMain->bmiHeader.biHeight= -(lvid->height);
bmiMain->bmiHeader.biPlanes = 1;
bmiMain->bmiHeader.biBitCount = 8;
bmiMain->bmiHeader.biCompression = BI_RGB;
// center window on the desktop
iScrWidth = GetSystemMetrics(SM_CXFULLSCREEN);
iScrHeight = GetSystemMetrics(SM_CYFULLSCREEN);
iWinWidth = lvid->width;
iWinWidth += GetSystemMetrics(SM_CXFIXEDFRAME) * 2;
iWinHeight = lvid->height;
iWinHeight += GetSystemMetrics(SM_CYCAPTION);
iWinHeight += GetSystemMetrics(SM_CYFIXEDFRAME) * 2;
if (devparm)
MoveWindow(hWndMain, (iScrWidth - iWinWidth), (iScrHeight - iWinHeight), iWinWidth, iWinHeight, TRUE);
else
MoveWindow(hWndMain, (iScrWidth - iWinWidth)>>1, (iScrHeight - iWinHeight)>>1, iWinWidth, iWinHeight, TRUE);
SetFocus(hWndMain);
ShowWindow(hWndMain, SW_SHOW);
hDCMain = GetDC(hWndMain);
if (!hDCMain)
I_Error("VID_SWDM(): GetDC FAILED");
return 1;
}
// ========================================================================
// Returns a vmode_t from the video modes list, given a video mode number.
// ========================================================================
vmode_t *VID_GetModePtr(int modenum)
{
vmode_t *pv;
pv = pvidmodes;
if (!pv)
I_Error("VID_error: No video mode found\n");
while (modenum--)
{
pv = pv->pnext;
if (!pv)
I_Error("VID_error: Mode not available\n");
}
return pv;
}
//
// return the name of a video mode
//
const char *VID_GetModeName(INT32 modenum)
{
return (VID_GetModePtr(modenum))->name;
}
// ========================================================================
// Sets a video mode
// ========================================================================
INT32 VID_SetMode(INT32 modenum)
{
int stat;
vmode_t *pnewmode;
vmode_t *poldmode;
if (dedicated)
return 0;
CONS_Printf("VID_SetMode(%d)\n", modenum);
// if mode 0 (windowed) we must not be fullscreen already,
// if other mode, check it is not mode 0 and existing
if (modenum >= numvidmodes)
{
if (!pcurrentmode)
modenum = 0; // revert to the default base vid mode
else
I_Error("Unknown video mode: %d\n", modenum);
}
else if (bAppFullScreen && modenum < NUMSPECIALMODES)
I_Error("Tried to switch from fullscreen back to windowed mode %d\n", modenum);
pnewmode = VID_GetModePtr(modenum);
// dont switch to the same display mode
if (pnewmode == pcurrentmode)
return 1;
// initialize the new mode
poldmode = pcurrentmode;
pcurrentmode = pnewmode;
// initialize vidbuffer size for setmode
vid.width = pcurrentmode->width;
vid.height = pcurrentmode->height;
vid.rowbytes = pcurrentmode->rowbytes;
vid.bpp = pcurrentmode->bytesperpixel;
if (modenum) // if not 320x200 windowed mode, it's actually a hack
{
if (rendermode == render_opengl)
{
// don't accept depth < 16 for OpenGL mode (too much ugly)
if (cv_scr_depth.value < 16)
CV_SetValue(&cv_scr_depth, 16);
vid.bpp = cv_scr_depth.value/8;
vid.u.windowed = (bWinParm || !cv_fullscreen.value);
pcurrentmode->bytesperpixel = vid.bpp;
pcurrentmode->windowed = vid.u.windowed;
}
}
stat = (*pcurrentmode->setmode)(&vid, pcurrentmode);
if (stat == -1)
I_Error("Not enough mem for VID_SetMode\n");
else if (stat == -2)
I_Error("Couldn't set video mode because it failed the test\n");
else if (stat == -3)
I_Error("Couldn't set video mode because it failed the change?\n");
else if (!stat)
I_Error("Couldn't set video mode %d (%dx%d %d bits)\n", modenum, vid.width, vid.height, (vid.bpp*8));// hardware could not setup mode
else
CONS_Printf(M_GetText("Mode changed to %d (%s)\n"), modenum, pcurrentmode->name);
vid.modenum = modenum;
// tell game engine to recalc all tables and realloc buffers based on new values
vid.recalc = 1;
if (modenum < NUMSPECIALMODES)
{
// we are in startup windowed mode
bAppFullScreen = FALSE;
bDIBMode = TRUE;
}
else
{
// we switch to fullscreen
bAppFullScreen = TRUE;
bDIBMode = FALSE;
#ifdef HWRENDER
if (rendermode != render_soft)
{
// purge all patch graphics stored in software format
//Z_FreeTags (PU_PURGELEVEL, PU_PURGELEVEL+100);
HWR_Startup();
}
#endif
}
I_RestartSysMouse();
return 1;
}
// ========================================================================
// Free the video buffer of the last video mode,
// allocate a new buffer for the video mode to set.
// ========================================================================
static BOOL VID_FreeAndAllocVidbuffer(viddef_t *lvid)
{
const DWORD vidbuffersize = (lvid->width * lvid->height * lvid->bpp * NUMSCREENS);
// free allocated buffer for previous video mode
if (lvid->buffer)
GlobalFree(lvid->buffer);
// allocate & clear the new screen buffer
lvid->buffer = GlobalAlloc(GPTR, vidbuffersize);
if (!lvid->buffer)
return FALSE;
ZeroMemory(lvid->buffer, vidbuffersize);
#ifdef DEBUG
CONS_Printf("VID_FreeAndAllocVidbuffer done, vidbuffersize: %x\n",vidbuffersize);
#endif
return TRUE;
}
// ========================================================================
// Set video mode routine for DirectDraw display modes
// Out: 1 ok,
// 0 hardware could not set mode,
// -1 no mem
// ========================================================================
static int WINAPI VID_SetDirectDrawMode(viddef_t *lvid, vmode_t *pcurrentmode)
{
pcurrentmode = NULL;
#ifdef DEBUG
CONS_Printf("VID_SetDirectDrawMode...\n");
#endif
// DD modes do double-buffer page flipping, but the game engine doesn't need this..
lvid->u.numpages = 2;
// release ddraw surfaces etc..
ReleaseChtuff();
// clean up any old vid buffer lying around, alloc new if needed
if (!VID_FreeAndAllocVidbuffer(lvid))
return -1; // no mem
// should clear video mem here
// note use lvid->bpp instead of 8...will this be needed? will we support other than 256color
// in software ?
if (!InitDirectDrawe(hWndMain, lvid->width, lvid->height, 8, TRUE)) // TRUE currently always full screen
return 0; // could not set mode
// this is NOT used with DirectDraw modes, game engine should never use this directly
// but rather render to memory bitmap buffer
lvid->direct = NULL;
if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT))
vid.height = (int)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match
return 1;
}
// ========================================================================
// VIDEO MODE CONSOLE COMMANDS
// ========================================================================
// vid_nummodes
//
static void VID_Command_NumModes_f(void)
{
CONS_Printf(M_GetText("%d video mode(s) available(s)\n"), VID_NumModes());
}
// vid_modeinfo <modenum>
//
static void VID_Command_ModeInfo_f(void)
{
vmode_t *pv;
int modenum;
if (COM_Argc() != 2)
modenum = vid.modenum; // describe the current mode
else
modenum = atoi(COM_Argv(1)); // the given mode number
if (modenum >= VID_NumModes() || modenum < NUMSPECIALMODES) // don't accept the windowed mode 0
{
CONS_Printf(M_GetText("Video mode not present\n"));
return;
}
pv = VID_GetModePtr(modenum);
CONS_Printf("%s\n", VID_GetModeName(modenum));
CONS_Printf(M_GetText("width: %d\nheight: %d\n"),
pv->width, pv->height);
if (rendermode == render_soft)
CONS_Printf(M_GetText("bytes per scanline: %d\nbytes per pixel: %d\nnumpages: %d\n"),
pv->rowbytes, pv->bytesperpixel, pv->numpages);
}
// vid_modelist
//
static void VID_Command_ModeList_f(void)
{
int i, nummodes;
const char *pinfo;
vmode_t *pv;
nummodes = VID_NumModes();
for (i = NUMSPECIALMODES; i <= nummodes; i++)
{
pv = VID_GetModePtr(i);
pinfo = VID_GetModeName(i);
if (pv->bytesperpixel == 1)
CONS_Printf("%d: %s\n", i, pinfo);
else
CONS_Printf("%d: %s (hicolor)\n", i, pinfo);
}
}
// vid_mode <modenum>
//
static void VID_Command_Mode_f(void)
{
int modenum;
if (COM_Argc() != 2)
{
CONS_Printf(M_GetText("vid_mode <modenum> : set video mode, current video mode %i\n"), vid.modenum);
return;
}
modenum = atoi(COM_Argv(1));
if (modenum >= VID_NumModes() || modenum < NUMSPECIALMODES) // don't accept the windowed mode 0
CONS_Printf(M_GetText("Video mode not present\n"));
else
setmodeneeded = modenum + 1; // request vid mode change
}

View file

@ -1,135 +0,0 @@
//It's 4am and im writing replacement string functions....
#include <stdlib.h>
#include <Windows.h>
#include "wince_stuff.h"
char* _strlwr( char *string )
{
int i;
if(!string)
return NULL;
for(i=0 ; i < strlen(string); i++)
{
if((*(string + i) >= 65) && (*(string + i) <= 90))
*(string+i) = *(string+i) + 32;
}
return string;
}
int _strnicmp(const char *first,const char *last, size_t count )
{
int f, l;
do
{
if ( ((f = (unsigned char)(*(first++))) >= 'A') && (f <= 'Z') )
f -= 'A' - 'a';
if ( ((l = (unsigned char)(*(last++))) >= 'A') && (l <= 'Z') )
l -= 'A' - 'a';
} while ( --count && f && (f == l) );
return ( f - l );
}
int _stricmp( const char *dst, const char *src )
{
int f, l;
do
{
if ( ((f = (unsigned char)(*(dst++))) >= 'A') && (f <= 'Z') )
f -= 'A' - 'a';
if ( ((l = (unsigned char)(*(src++))) >= 'A') && (l <= 'Z') )
l -= 'A' - 'a';
} while ( f && (f == l) );
return(f - l);
}
char* _strupr( char *string )
{
int i;
if(!string)
return NULL;
for(i=0 ; i < strlen(string); i++)
{
if((*(string + i) >= 97) && (*(string + i) <= 122))
*(string + i) = *(string + i) - 32;
}
return string;
}
int isprint( int c )
{
if(c <= 31)
return FALSE;
return TRUE;
}
char* _strdup (const char * string)
{
char *memory = NULL;
if (!string)
return(NULL);
if (memory = malloc(strlen(string) + 1))
return(strcpy(memory,string));
return(NULL);
}
char* strrchr (const char * string,int ch)
{
char *start = (char *)string;
while (*string++) /* find end of string */
;
/* search towards front */
while (--string != start && *string != (char)ch)
;
if (*string == (char)ch) /* char found ? */
return( (char *)string );
return(NULL);
}
char* GetMyCWD(void)
{
TCHAR fn[MAX_PATH];
char* my_cwd,*p;
GetModuleFileName(NULL,fn,MAX_PATH);
my_cwd = (char*)malloc(MAX_PATH*sizeof(char));
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR | WC_SEPCHARS, fn, -1, my_cwd, MAX_PATH, NULL, NULL);
p = strrchr(my_cwd,'\\');
if(p)
*(p+1) = '\0';
return my_cwd;
}

View file

@ -1,17 +0,0 @@
#ifndef WINCE_STUFF_H
#define WINCE_STUFF_H
/*
char* _strlwr(char *string);
int _strnicmp(const char *string1,const char *string2, size_t count );
int _stricmp( const char *string1, const char *string2 );
char* _strupr( char *string );
char *_strdup( const char *strSource );
char *strrchr( const char *string, int c );
int isprint( int c );
*/
char* GetMyCWD(void);
#endif