From 183e45e8d0b4425bbd41fab37f2a4dc143e1e27c Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Sun, 28 Jul 2019 23:31:50 +0300 Subject: [PATCH] sdl: Remove platform-specific code Also nuke the Makefiles of Duke Nukem 3D (pun intended). Change-Id: If2707cf079bfb9299347f9c5f980780134b6ecda --- apps/plugins/sdl/SDL_mixer/music.c | 2 - apps/plugins/sdl/include/SDL_config.h.in | 2 - apps/plugins/sdl/include/SDL_opengl.h | 5 - .../sdl/progs/duke3d/Engine/src/build.h | 15 +- .../sdl/progs/duke3d/Engine/src/display.c | 37 -- .../sdl/progs/duke3d/Engine/src/draw.h | 6 +- .../sdl/progs/duke3d/Engine/src/engine.c | 6 - .../sdl/progs/duke3d/Engine/src/filesystem.h | 2 - .../progs/duke3d/Engine/src/macos_compat.h | 62 --- .../sdl/progs/duke3d/Engine/src/mmulti.c | 118 ------ .../sdl/progs/duke3d/Engine/src/multi.c | 194 --------- .../sdl/progs/duke3d/Engine/src/platform.h | 16 +- .../sdl/progs/duke3d/Engine/src/unix_compat.h | 67 ---- .../progs/duke3d/Engine/src/win32_compat.h | 106 ----- .../sdl/progs/duke3d/Game/src/audiolib/dpmi.h | 4 - .../progs/duke3d/Game/src/audiolib/fx_man.h | 6 +- .../progs/duke3d/Game/src/audiolib/task_man.c | 118 ------ .../sdl/progs/duke3d/Game/src/config.c | 12 - .../sdl/progs/duke3d/Game/src/cvar_defs.h | 6 +- .../plugins/sdl/progs/duke3d/Game/src/cvars.h | 6 +- .../sdl/progs/duke3d/Game/src/duke3d.h | 29 -- .../sdl/progs/duke3d/Game/src/dukerockbox.h | 19 - .../sdl/progs/duke3d/Game/src/dukeunix.h | 100 ----- .../sdl/progs/duke3d/Game/src/dukewin.h | 86 ---- apps/plugins/sdl/progs/duke3d/Game/src/game.c | 101 ----- .../sdl/progs/duke3d/Game/src/gamedef.c | 20 - .../sdl/progs/duke3d/Game/src/global.c | 139 +------ .../sdl/progs/duke3d/Game/src/global.h | 25 +- .../sdl/progs/duke3d/Game/src/menues.c | 130 ++---- .../sdl/progs/duke3d/Game/src/sounds.c | 4 - .../plugins/sdl/progs/duke3d/Game/src/types.h | 6 +- .../sdl/progs/duke3d/Game/src/util_lib.h | 6 +- apps/plugins/sdl/progs/quake/cl_parse.c | 6 - apps/plugins/sdl/progs/quake/common.c | 7 - apps/plugins/sdl/progs/quake/host.c | 10 - apps/plugins/sdl/progs/quake/mathlib.c | 8 - apps/plugins/sdl/progs/quake/menu.c | 79 ---- apps/plugins/sdl/progs/quake/net.h | 2 +- apps/plugins/sdl/progs/quake/net_dgrm.c | 4 +- apps/plugins/sdl/progs/quake/quakeasm.h | 8 - apps/plugins/sdl/progs/quake/quakedef.h | 13 - apps/plugins/sdl/progs/quake/snd_dma.c | 72 +--- apps/plugins/sdl/progs/quake/vid.h | 4 - apps/plugins/sdl/progs/quake/winquake.h | 115 ------ apps/plugins/sdl/progs/wolf3d/sdl_winmain.c | 378 ------------------ apps/plugins/sdl/progs/wolf3d/wl_def.h | 26 +- apps/plugins/sdl/progs/wolf3d/wl_main.c | 25 +- apps/plugins/sdl/progs/wolf3d/wl_menu.c | 6 - apps/plugins/sdl/src/stdlib/SDL_malloc.c | 26 -- 49 files changed, 53 insertions(+), 2191 deletions(-) delete mode 100644 apps/plugins/sdl/progs/duke3d/Engine/src/macos_compat.h delete mode 100644 apps/plugins/sdl/progs/duke3d/Engine/src/unix_compat.h delete mode 100644 apps/plugins/sdl/progs/duke3d/Engine/src/win32_compat.h delete mode 100644 apps/plugins/sdl/progs/duke3d/Game/src/dukeunix.h delete mode 100644 apps/plugins/sdl/progs/duke3d/Game/src/dukewin.h delete mode 100644 apps/plugins/sdl/progs/quake/winquake.h delete mode 100644 apps/plugins/sdl/progs/wolf3d/sdl_winmain.c diff --git a/apps/plugins/sdl/SDL_mixer/music.c b/apps/plugins/sdl/SDL_mixer/music.c index ab41327394..dce16a9de3 100644 --- a/apps/plugins/sdl/SDL_mixer/music.c +++ b/apps/plugins/sdl/SDL_mixer/music.c @@ -1582,8 +1582,6 @@ int Mix_EachSoundFont(int (*function)(const char*, void*), void *data) #if defined(__MINGW32__) || defined(__MINGW64__) for (path = strtok(paths, ";"); path; path = strtok(NULL, ";")) { -#elif defined(_WIN32) - for (path = strtok_s(paths, ";", &context); path; path = strtok_s(NULL, ";", &context)) { #else for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) { #endif diff --git a/apps/plugins/sdl/include/SDL_config.h.in b/apps/plugins/sdl/include/SDL_config.h.in index 8bb1773c0e..7f3110188f 100644 --- a/apps/plugins/sdl/include/SDL_config.h.in +++ b/apps/plugins/sdl/include/SDL_config.h.in @@ -83,11 +83,9 @@ #undef HAVE_REALLOC #undef HAVE_FREE #undef HAVE_ALLOCA -#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */ #undef HAVE_GETENV #undef HAVE_PUTENV #undef HAVE_UNSETENV -#endif #undef HAVE_QSORT #undef HAVE_ABS #undef HAVE_BCOPY diff --git a/apps/plugins/sdl/include/SDL_opengl.h b/apps/plugins/sdl/include/SDL_opengl.h index 3d791d69b3..abf5ccc4e5 100644 --- a/apps/plugins/sdl/include/SDL_opengl.h +++ b/apps/plugins/sdl/include/SDL_opengl.h @@ -93,11 +93,6 @@ extern "C" { ** version 1.2.1 Specification. */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - #ifndef APIENTRY #define APIENTRY #endif diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/build.h b/apps/plugins/sdl/progs/duke3d/Engine/src/build.h index f0389e54e2..c2934b62dd 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/build.h +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/build.h @@ -7,11 +7,8 @@ #ifndef _INCLUDE_BUILD_H_ #define _INCLUDE_BUILD_H_ -#ifdef _WIN32 - #include "windows/inttypes.h" -#else - #include -#endif + +#include #define MAXSECTORS 1024 #define MAXWALLS 8192 @@ -223,12 +220,8 @@ SPRITE VARIABLES: Example: if the linked lists look like the following: ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ - ³ Sector lists: Status lists: ³ - ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ - ³ Sector0: 4, 5, 8 Status0: 2, 0, 8 ³ - ³ Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 ³ - ³ Sector2: 3, 9 ³ - ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + ? Sector lists: Status lists: ? ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ + ? Sector0: 4, 5, 8 Status0: 2, 0, 8 ? ? Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 ? ? Sector2: 3, 9 ? ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Notice that each number listed above is shown exactly once on both the left and right side. This is because any sprite that exists must be in some sector, and must have some kind of status that you define. diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/display.c b/apps/plugins/sdl/progs/duke3d/Engine/src/display.c index 501ffa411c..c16c8fb25c 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/display.c +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/display.c @@ -69,10 +69,6 @@ void TIMER_GetPlatformTicks(int64_t* t); -#if ((defined PLATFORM_WIN32)) -#include -#endif - #include "draw.h" #include "cache.h" @@ -763,12 +759,6 @@ void _platform_init(int argc, char **argv, const char *title, const char *ico } - -#ifdef __APPLE__ - SDL_putenv("SDL_VIDEODRIVER=Quartz"); -#endif - - if (SDL_Init(SDL_INIT_VIDEO) == -1){ Error(EXIT_FAILURE, "BUILDSDL: SDL_Init() failed!\nBUILDSDL: SDL_GetError() says \"%s\".\n", SDL_GetError()); } @@ -946,14 +936,11 @@ int32_t _setgamemode(uint8_t davidoption, int32_t daxdim, int32_t daydim) SDL_Surface *image; Uint32 colorkey; - // don't override higher-res app icon on OS X -#ifndef PLATFORM_MACOSX // Install icon image = SDL_LoadBMP_RW(SDL_RWFromMem(iconBMP, iconBMP_size), 1); colorkey = 0; // index in this image to be transparent SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey); SDL_WM_SetIcon(image,NULL); -#endif if (daxdim > MAXXDIM || daydim > MAXYDIM) { @@ -1915,29 +1902,6 @@ void uninitkeys(void) /* does nothing in SDL. Key input handling is set up elsewhere. */ } - -//unsigned int32_t getticks(void) -//{ -// return(SDL_GetTicks()); -//} /* getticks */ - - -//Timer on windows 98 used to be really poor but now it is very accurate -// We can just use what SDL uses, no need for QueryPerformanceFrequency or QueryPerformanceCounter -// (which I bet SDL is using anyway). -#if 0//PLATFORM_WIN32 -int TIMER_GetPlatformTicksInOneSecond(int64_t* t) -{ - QueryPerformanceFrequency((LARGE_INTEGER*)t); - return 1; -} - -void TIMER_GetPlatformTicks(int64_t* t) -{ - QueryPerformanceCounter((LARGE_INTEGER*)t); -} -#else -//FCS: Let's try to use SDL again: Maybe SDL library is accurate enough now. int TIMER_GetPlatformTicksInOneSecond(int64_t* t) { *t = 1000; @@ -1948,6 +1912,5 @@ void TIMER_GetPlatformTicks(int64_t* t) { *t = SDL_GetTicks(); } -#endif /* end of sdl_driver.c ... */ diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/draw.h b/apps/plugins/sdl/progs/duke3d/Engine/src/draw.h index 0f2a656b6a..eff82c9e0d 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/draw.h +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/draw.h @@ -8,11 +8,7 @@ #ifndef _INCLUDE_A_H_ #define _INCLUDE_A_H_ -#ifdef _WIN32 - #include "windows/inttypes.h" -#else - #include -#endif +#include //C++ linker friendly diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/engine.c b/apps/plugins/sdl/progs/duke3d/Engine/src/engine.c index c0a7390882..b3b807d706 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/engine.c +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/engine.c @@ -3335,13 +3335,7 @@ int saveboard(char *filename, int32_t *daposx, int32_t *daposy, walltype *w; sectortype *sect; -#if ((defined PLATFORM_DOS) || (defined PLATFORM_WIN32)) - permissions = S_IWRITE; -#elif (defined PLATFORM_UNIX) - permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; -#elif (defined PLATFORM_ROCKBOX) permissions = 0644; -#endif if ((fil = rb->open(filename, O_BINARY|O_TRUNC|O_CREAT|O_WRONLY, diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/filesystem.h b/apps/plugins/sdl/progs/duke3d/Engine/src/filesystem.h index 59e0e9e530..fe172072b5 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/filesystem.h +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/filesystem.h @@ -42,8 +42,6 @@ void setGameDir(char* gameDir); int32_t TCkopen4load(const char *filename, int32_t readfromGRP); -#if defined(__APPLE__) || defined(__linux__) int32_t filelength(int32_t fd); -#endif #endif diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/macos_compat.h b/apps/plugins/sdl/progs/duke3d/Engine/src/macos_compat.h deleted file mode 100644 index 7eb205daa6..0000000000 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/macos_compat.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// macos_compat.h -// Duke3D -// -// Created by fabien sanglard on 12-12-12. -// Copyright (c) 2012 fabien sanglard. All rights reserved. -// - -#ifndef Duke3D_macos_compat_h -#define Duke3D_macos_compat_h - -#define PLATFORM_SUPPORTS_SDL - -#include - -#define kmalloc(x) malloc(x) -#define kkmalloc(x) malloc(x) -#define kfree(x) free(x) -#define kkfree(x) free(x) - -#ifdef FP_OFF -#undef FP_OFF -#endif - -// Horrible horrible macro: Watcom allowed memory pointer to be cast -// to a 32bits integer. The code is unfortunately stuffed with this :( ! -#define FP_OFF(x) ((int32_t) (x)) - -#ifndef max -#define max(x, y) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef min -#define min(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -#include -#define __int64 int64_t - -#define O_BINARY 0 - -#define UDP_NETWORKING 1 - -#define PLATFORM_MACOSX 1 - -#define SOL_IP SOL_SOCKET -#define IP_RECVERR SO_BROADCAST - -#define stricmp strcasecmp -#define strcmpi strcasecmp - -#include -#include -#include -#include -#include -#include -#include - -#define USER_DUMMY_NETWORK 1 - -#endif diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/mmulti.c b/apps/plugins/sdl/progs/duke3d/Engine/src/mmulti.c index dea2b7d35c..9d2afe9d33 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/mmulti.c +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/mmulti.c @@ -557,49 +557,8 @@ void deinit_network_transport(gcomtype *gcom) void unstable_callcommit(void){} -#elif (defined PLATFORM_DOS) -gcomtype *init_network_transport(char **ARGV, int argpos) -{ - /* - * How to talk to COMMIT is passed as a pointer to a block of memory - * that COMMIT.EXE configures... - */ - return((gcomtype *)atol(ARGV[argpos])); /* UGH! --ryan. */ -} /* init_network_transport */ - -static union REGS regs; - -#pragma aux longcall =\ - "call eax",\ - parm [eax] - -void callcommit(void) -{ - if (gcom->intnum&0xff00) - longcall(gcom->longcalladdress); - else - int386(gcom->intnum,®s,®s); -} - -void deinit_network_transport(gcomtype *gcom) -{ - /* no-op, apparently. */ -} - - #elif UDP_NETWORKING -#if PLATFORM_WIN32 -# include -# define EAGAIN WSAEWOULDBLOCK -# define EWOULDBLOCK WSAEWOULDBLOCK -# define ECONNREFUSED WSAECONNRESET -# define socklen_t size_t -# define netstrerror() win32netstrerror() -# define neterrno() WSAGetLastError() -# define sockettype SOCKET -# define socketclose(x) closesocket(x) -#else # include # include # include @@ -618,7 +577,6 @@ void deinit_network_transport(gcomtype *gcom) # ifndef MSG_ERRQUEUE /* legacy glibc header workaround... */ # define MSG_ERRQUEUE 0x2000 # endif -#endif #define SOCKET_SHUTDOWN_BOTH 2 @@ -650,47 +608,6 @@ static void siginthandler(int sigint) ctrlc_pressed = 1; } -#if PLATFORM_WIN32 -/* - * Figure out what the last failing Win32 API call was, and - * generate a human-readable string for the error message. - * - * The return value is a static buffer that is overwritten with - * each call to this function. - * - * Code lifted from PhysicsFS: http://icculus.org/physfs/ - */ -static const char *win32netstrerror(void) -{ - static TCHAR msgbuf[255]; - TCHAR *ptr = msgbuf; - - FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - WSAGetLastError(), /*GetLastError(),*/ - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ - msgbuf, - sizeof (msgbuf) / sizeof (TCHAR), - NULL - ); - - /* chop off newlines. */ - for (ptr = msgbuf; *ptr; ptr++) - { - if ((*ptr == '\n') || (*ptr == '\r')) - { - *ptr = ' '; - break; - } /* if */ - } /* for */ - - return((const char *) msgbuf); -} /* win32strerror */ -#endif - - typedef enum { udpmode_peer, @@ -758,7 +675,6 @@ static int get_udp_packet(int *ip, short *_port, void *pkt, size_t pktsize) if (rc == -1) err = neterrno(); -#if !PLATFORM_WIN32 /* !!! FIXME: Linux specific? */ if (rc == -1) /* fill in the addr structure on error... */ { @@ -766,7 +682,6 @@ static int get_udp_packet(int *ip, short *_port, void *pkt, size_t pktsize) recvfrom(udpsocket, NULL, 0, MSG_ERRQUEUE, (struct sockaddr *) &addr, &l); } -#endif *ip = ntohl(addr.sin_addr.s_addr); port = ntohs(addr.sin_port); @@ -933,10 +848,6 @@ static int set_socket_blockmode(int onOrOff) /* set socket to be (non-)blocking. */ -#if PLATFORM_WIN32 - flags = (onOrOff) ? 0 : 1; - rc = (ioctlsocket(udpsocket, FIONBIO, &flags) == 0); -#else flags = fcntl(udpsocket, F_GETFL, 0); if (flags != -1) { @@ -946,7 +857,6 @@ static int set_socket_blockmode(int onOrOff) flags |= O_NONBLOCK; rc = (fcntl(udpsocket, F_SETFL, flags) == 0); } -#endif if (!rc) { @@ -992,13 +902,11 @@ static int open_udp_socket(int ip, int port) if (!set_socket_blockmode(0)) return(0); - #if !PLATFORM_WIN32 { /* !!! FIXME: Might be Linux (not Unix, not BSD, not WinSock) specific. */ int flags = 1; setsockopt(udpsocket, SOL_IP, IP_RECVERR, &flags, sizeof (flags)); } - #endif memset(&addr, '\0', sizeof (addr)); addr.sin_family = AF_INET; @@ -1376,37 +1284,11 @@ static int parse_interface(char *str, int *ip, short *udpport) static int initialize_sockets(void) { -#if PLATFORM_WIN32 - int rc; - WSADATA data; - printf("initializing WinSock...\n"); - rc = WSAStartup(0x0101, &data); - if (rc != 0) - { - printf("WinSock failed to initialize! [err==%d].\n", rc); - return(0); - } - else - { - printf("WinSock initialized.\n"); - printf(" - Caller uses version %d.%d, highest supported is %d.%d.\n", - data.wVersion >> 8, data.wVersion & 0xFF, - data.wHighVersion >> 8, data.wHighVersion & 0xFF); - printf(" - Implementation description: [%s].\n", data.szDescription); - printf(" - System status: [%s].\n", data.szSystemStatus); - printf(" - Max sockets: %d.\n", data.iMaxSockets); - printf(" - Max UDP datagram size: %d.\n", data.iMaxUdpDg); - } -#endif - return(1); } static void deinitialize_sockets(void) { -#if PLATFORM_WIN32 - WSACleanup(); -#endif } static int parse_udp_config(const char *cfgfile, gcomtype *gcom) diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c b/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c index c2ded00914..b23481bc08 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/multi.c @@ -46,39 +46,9 @@ long crctable[256]; //COM ONLY variables long comnum, comvect, comspeed, comtemp, comi, comescape, comreset; -#ifdef PLATFORM_DOS // !!! this is a real mess. --ryan. -static void interrupt far comhandler(void); -static unsigned short orig_pm_sel, orig_rm_seg, orig_rm_off; -static unsigned long orig_pm_off; -#endif volatile unsigned char *inbuf, *outbuf, *comerror, *incnt, *comtype; volatile unsigned char *comresend; volatile short *inbufplc, *inbufend, *outbufplc, *outbufend, *comport; -#ifdef PLATFORM_DOS // !!! this is a real mess. --ryan. -static char rmbuffer[COMCODEBYTES] = //See realcom.asm -{ - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x50,0x53,0x66,0x51,0x52,0x2e, - 0x8b,0x16,0x08,0x00,0x83,0xc2,0x02,0xec,0x24,0x07, - 0x8a,0xe0,0x80,0xfc,0x02,0x74,0x08,0x80,0xfc,0x04, - 0x74,0x62,0xe9,0x89,0x00,0x2e,0x8b,0x16,0x08,0x00, - 0x2e,0x8a,0x0e,0x0a,0x00,0x80,0xe9,0x01,0x78,0x7a, - 0x2e,0x80,0x3e,0x0c,0x00,0x01,0x7c,0x10,0x74,0x04, - 0xb0,0x83,0xeb,0x02,0xb0,0x8f,0xee,0x2e,0xfe,0x0e, - 0x0c,0x00,0xeb,0xe3,0x2e,0x80,0x3e,0x0b,0x00,0x01, - 0x7c,0x12,0x74,0x04,0xb0,0x83,0xeb,0x04,0x2e,0xa0, - 0x0d,0x00,0xee,0x2e,0xfe,0x0e,0x0b,0x00,0xeb,0xc9, - 0x2e,0x8b,0x1e,0x04,0x00,0x2e,0x3b,0x1e,0x06,0x00, - 0x74,0x3c,0x2e,0x8a,0x87,0x80,0x41,0xee,0x43,0x81, - 0xe3,0xff,0x3f,0x2e,0x89,0x1e,0x04,0x00,0xeb,0xab, - 0x2e,0x8b,0x16,0x08,0x00,0xec,0x2e,0x8b,0x1e,0x02, - 0x00,0x2e,0x88,0x87,0x80,0x01,0x43,0x81,0xe3,0xff, - 0x3f,0x2e,0x89,0x1e,0x02,0x00,0x2e,0x80,0x3e,0x0a, - 0x00,0x10,0x75,0x08,0x83,0xc2,0x05,0xec,0xa8,0x01, - 0x75,0xd6,0xf6,0xc4,0x01,0x0f,0x84,0x56,0xff,0xb0, - 0x20,0xe6,0x20,0x5a,0x66,0x59,0x5b,0x58,0xcf, -}; -#endif //NET ONLY variables short socket = 0x4949; @@ -106,80 +76,17 @@ static char rmnetbuffer[NETCODEBYTES] = }; static long my7a = 0; -#ifdef PLATFORM_DOS -#pragma aux koutp =\ - "out dx, al",\ - parm [edx][eax]\ - -#pragma aux kinp =\ - "in al, dx",\ - parm [edx] -#endif - long convalloc32 (long size) { -#ifdef PLATFORM_DOS - union REGS r; - - r.x.eax = 0x0100; //DPMI allocate DOS memory - r.x.ebx = ((size+15)>>4); //Number of paragraphs requested - int386(0x31,&r,&r); - - if (r.x.cflag != 0) return ((long)0); //Failed - return ((long)((r.x.eax&0xffff)<<4)); //Returns full 32-bit offset -#else fprintf (stderr, "%s, line %d; convalloc32() called\n", __FILE__, __LINE__); return 0; -#endif } -#ifdef PLATFORM_DOS -#pragma aux fixregistersaftersimulate =\ - "cld",\ - "push ds",\ - "pop es",\ - -static struct rminfo -{ - long EDI, ESI, EBP, ESP, EBX, EDX, ECX, EAX; - short flags, ES, DS, FS, GS, IP, CS, SP, SS; -} RMI; -#endif - long simulateint(char intnum, long daeax, long daebx, long daecx, long daedx, long daesi, long daedi) { -#ifdef PLATFORM_DOS - union REGS regs; - struct SREGS sregs; - - memset(&RMI,0,sizeof(RMI)); // Set up real-mode call structure - memset(&sregs,0,sizeof(sregs)); - - RMI.EAX = daeax; - RMI.EBX = daebx; - RMI.ECX = daecx; - RMI.EDX = daedx; - RMI.ESI = daesi-rmoffset32; - RMI.EDI = daedi-rmoffset32; - RMI.DS = rmsegment16; - RMI.ES = rmsegment16; - - regs.w.ax = 0x0300; // Use DMPI call 300h to issue the DOS interrupt - regs.h.bl = intnum; - regs.h.bh = 0; - regs.w.cx = 0; - sregs.es = FP_SEG(&RMI); - regs.x.edi = FP_OFF(&RMI); - int386x(0x31,®s,®s,&sregs); - - fixregistersaftersimulate(); - - return(RMI.EAX); -#else fprintf(stderr, "%s line %d; simulateint() called\n",__FILE__,__LINE__); return 0; -#endif } void initmultiplayers(char damultioption, char dacomrateoption, char dapriority) @@ -237,22 +144,6 @@ int neton(void) long i, j; if ((simulateint(0x2f,(long)0x7a00,0L,0L,0L,0L,0L)&255) != 255) return(-1); - if (*(long *)(0x7a<<2) == 0) - { -#ifdef PLATFORM_DOS - printf("Faking int 0x7a to call IPX entry at: %4x:%4x\n",RMI.ES,RMI.EDI&65535); - my7a = convalloc32(16L); - *(short *)((0x7a<<2)+0) = (my7a&15); - *(short *)((0x7a<<2)+2) = (my7a>>4); - - *(char *)(my7a+0) = 0x2e; //call far ptr [L1] - *(char *)(my7a+1) = 0x9a; - *(long *)(my7a+2) = 7L; - *(char *)(my7a+6) = 0xcf; //iret - *(short *)(my7a+7) = (RMI.EDI&65535); //L1: ipxoff - *(short *)(my7a+9) = RMI.ES; // ipxseg -#endif - } //Special stuff for WATCOM C if ((rmoffset32 = convalloc32(1380L+NETCODEBYTES+COMBUFSIZ)) == 0) @@ -349,9 +240,6 @@ int comon() // Baud-Setting,?,?,Parity O/E,Parity Off/On, Stop-1/2,Bits-5/6/7/8 // 0x0b is odd parity,1 stop bit, 8 bits -#ifdef PLATFORM_DOS - _disable(); -#endif koutp((*comport)+3,0x80); //enable latch registers divisor = 115200 / comspeed; koutp((*comport)+0,divisor&255); //# = 115200 / bps @@ -384,9 +272,6 @@ int comon() comescape = 0; comreset = 0; *comerror = 0; *comresend = 0; -#ifdef PLATFORM_DOS - _enable(); -#endif syncbufleng = 0; @@ -410,18 +295,12 @@ void comoff() i--; } -#ifdef PLATFORM_DOS - _disable(); -#endif koutp(0x21,kinp(0x21)|(1<<(comvect&7))); //Mask vector if (hangup != 0) { koutp((*comport)+1,0); koutp((*comport)+4,0); } -#ifdef PLATFORM_DOS - _enable(); -#endif uninstallbicomhandlers(); } @@ -921,87 +800,14 @@ long getcrc(char *buffer, short bufleng) void installbicomhandlers(void) { -#ifdef PLATFORM_DOS - union REGS r; - struct SREGS sr; - long lowp; - void far *fh; - - //Get old protected mode handler - r.x.eax = 0x3500+comvect; /* DOS get vector (INT 0Ch) */ - sr.ds = sr.es = 0; - int386x(0x21,&r,&r,&sr); - orig_pm_sel = (unsigned short)sr.es; - orig_pm_off = r.x.ebx; - - //Get old real mode handler - r.x.eax = 0x0200; /* DPMI get real mode vector */ - r.h.bl = comvect; - int386(0x31,&r,&r); - orig_rm_seg = (unsigned short)r.x.ecx; - orig_rm_off = (unsigned short)r.x.edx; - - //Allocate memory in low memory to store real mode handler - if ((lowp = convalloc32(COMCODEBYTES+(COMBUFSIZ<<1))) == 0) - { printf("Can't allocate conventional memory.\n"); exit; } - - inbufplc = (short *)(lowp+0); - inbufend = (short *)(lowp+2); - outbufplc = (short *)(lowp+4); - outbufend = (short *)(lowp+6); - comport = (short *)(lowp+8); - comtype = (char *)(lowp+10); - comerror = (char *)(lowp+11); - comresend = (char *)(lowp+12); - incnt = (char *)(lowp+13); - inbuf = (char *)(lowp+COMCODEBYTES); - outbuf = (char *)(lowp+COMCODEBYTES+COMBUFSIZ); - - memcpy((void *)lowp,(void *)rmbuffer,COMCODEBYTES); - - //Set new protected mode handler - r.x.eax = 0x2500+comvect; /* DOS set vector (INT 0Ch) */ - fh = (void far *)comhandler; - r.x.edx = FP_OFF(fh); - sr.ds = FP_SEG(fh); //DS:EDX == &handler - sr.es = 0; - int386x(0x21,&r,&r,&sr); - - //Set new real mode handler (must be after setting protected mode) - r.x.eax = 0x0201; - r.h.bl = comvect; //CX:DX == real mode &handler - r.x.ecx = ((lowp>>4)&0xffff); //D32realseg - r.x.edx = COMCODEOFFS; //D32realoff - int386(0x31,&r,&r); -#else fprintf (stderr,"%s, line %d; installbicomhandlers() called\n", __FILE__, __LINE__); -#endif } void uninstallbicomhandlers(void) { -#ifdef PLATFORM_DOS - union REGS r; - struct SREGS sr; - - //restore old protected mode handler - r.x.eax = 0x2500+comvect; /* DOS set vector (INT 0Ch) */ - r.x.edx = orig_pm_off; - sr.ds = orig_pm_sel; /* DS:EDX == &handler */ - sr.es = 0; - int386x(0x21,&r,&r,&sr); - - //restore old real mode handler - r.x.eax = 0x0201; /* DPMI set real mode vector */ - r.h.bl = comvect; - r.x.ecx = (unsigned long)orig_rm_seg; //CX:DX == real mode &handler - r.x.edx = (unsigned long)orig_rm_off; - int386(0x31,&r,&r); -#else fprintf (stderr, "%s line %d; uninstallbicomhandlers() called\n", __FILE__, __LINE__); -#endif } void processreservedmessage(short tempbufleng, char *datempbuf) diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/platform.h b/apps/plugins/sdl/progs/duke3d/Engine/src/platform.h index a8cfe1843e..6d91d25530 100644 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/platform.h +++ b/apps/plugins/sdl/progs/duke3d/Engine/src/platform.h @@ -1,15 +1,7 @@ #ifndef _INCLUDE_PLATFORM_DUKE_H_ #define _INCLUDE_PLATFORM_DUKE_H_ -#if (defined PLATFORM_WIN32) - #include "win32_compat.h" -#elif (defined PLATFORM_UNIX) - #include "unix_compat.h" -#elif (defined PLATFORM_DOS) - #include "doscmpat.h" -#elif (defined __APPLE__) - #include "macos_compat.h" -#elif (defined ROCKBOX) +#if (defined ROCKBOX) #include "rockbox_compat.h" #else #error Define your platform! @@ -21,15 +13,9 @@ uint16_t _swap16(uint16_t D); unsigned int _swap32(unsigned int D); -#if defined(PLATFORM_MACOSX) && defined(__ppc__) -#define PLATFORM_BIGENDIAN 1 -#define BUILDSWAP_INTEL16(x) _swap16(x) -#define BUILDSWAP_INTEL32(x) _swap32(x) -#else #define PLATFORM_LITTLEENDIAN 1 #define BUILDSWAP_INTEL16(x) (x) #define BUILDSWAP_INTEL32(x) (x) -#endif #endif /* !defined _INCLUDE_PLATFORM_H_ */ diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/unix_compat.h b/apps/plugins/sdl/progs/duke3d/Engine/src/unix_compat.h deleted file mode 100644 index 811e99ea08..0000000000 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/unix_compat.h +++ /dev/null @@ -1,67 +0,0 @@ -// -// unix_compat.h -// Duke3D -// -// Based on macos_compat.h -// Copyright Wed, Jul 31, 2013, Juan Manuel Borges Caño (GPLv3+) -// - -#ifndef Duke3D_unix_compat_h -#define Duke3D_unix_compat_h - -//#define BYTE_ORDER LITTLE_ENDIAN -#define PLATFORM_SUPPORTS_SDL - -#include - -#define kmalloc(x) malloc(x) -#define kkmalloc(x) malloc(x) -#define kfree(x) free(x) -#define kkfree(x) free(x) - -#ifdef FP_OFF -#undef FP_OFF -#endif - -// Horrible horrible macro: Watcom allowed memory pointer to be cast -// to a 32bits integer. The code is unfortunately stuffed with this :( ! -#define FP_OFF(x) ((int32_t) (x)) - -#ifndef max -#define max(x, y) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef min -#define min(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -#include -#define __int64 int64_t - -#define O_BINARY 0 - -#define UDP_NETWORKING 1 - -#define PLATFORM_UNIX 1 - -/* -#define SOL_IP SOL_SOCKET -#define IP_RECVERR SO_BROADCAST -*/ - -#define stricmp strcasecmp -#define strcmpi strcasecmp - -#define S_IREAD S_IRUSR -#include -#include -#include -#include -#include -#include -#include -#include - -#define USER_DUMMY_NETWORK 1 - -#endif diff --git a/apps/plugins/sdl/progs/duke3d/Engine/src/win32_compat.h b/apps/plugins/sdl/progs/duke3d/Engine/src/win32_compat.h deleted file mode 100644 index e509e9bf37..0000000000 --- a/apps/plugins/sdl/progs/duke3d/Engine/src/win32_compat.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * win32 compatibility header. Takes care of some legacy code issues - * and incompatibilities at the source level. - * - * Written by Ryan C. Gordon (icculus@clutteredmind.org) - * - * Please do NOT harrass Ken Silverman about any code modifications - * (including this file) to BUILD. - */ - -/* - * "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman - * Ken Silverman's official web site: "http://www.advsys.net/ken" - * See the included license file "BUILDLIC.TXT" for license info. - * This file IS NOT A PART OF Ken Silverman's original release - */ - - - -#ifndef _INCLUDE_WIN32_COMPAT_H_ -#define _INCLUDE_WIN32_COMPAT_H_ - -#if (!defined PLATFORM_WIN32) -#error PLATFORM_WIN32 is not defined. -#endif - -#define PLATFORM_SUPPORTS_SDL - -#include - -#if (!defined _MSC_VER) - #include -#else - #include - #include -#endif - -#include -#include -#include -#include -#include -#include -#include - -#define kmalloc(x) malloc(x) -#define kkmalloc(x) malloc(x) -#define kfree(x) free(x) -#define kkfree(x) free(x) - -#ifdef FP_OFF -#undef FP_OFF -#endif - -#define FP_OFF(x) ((long) (x)) - -/* !!! This might be temporary. */ -#define printext16 printext256 -#define printext16_noupdate printext256_noupdate - -#ifndef max -#define max(x, y) (((x) > (y)) ? (x) : (y)) -#endif - -#ifndef min -#define min(x, y) (((x) < (y)) ? (x) : (y)) -#endif - -#if (defined __WATCOMC__) -#define inline -#pragma intrinsic(min); -#pragma intrinsic(max); -#define __int64 long long -#endif - -#if (defined _MSC_VER) -#if ((!defined _INTEGRAL_MAX_BITS) || (_INTEGRAL_MAX_BITS < 64)) -#error __int64 type not supported -#endif - -#define open _open -#define O_BINARY _O_BINARY -#define O_RDONLY _O_RDONLY -#define O_WRONLY _O_WRONLY -#define O_RDWR _O_RDWR -#define O_TRUNC _O_TRUNC -#define O_CREAT _O_CREAT -#define S_IREAD _S_IREAD -#define S_IWRITE _S_IWRITE -#define S_IRDWR _S_IRDWR -#endif /* defined _MSC_VER */ - -#define snprintf _snprintf - -#define strncasecmp strnicmp - -//Damn you Microsoft, how hard would it REALLY be to support C99 ?!??!?! -#define inline -#include "windows/inttypes.h" - -#endif - -/* end of win32_compat.h ... */ - - - diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/dpmi.h b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/dpmi.h index 0ca6b93a6a..adfb216f03 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/dpmi.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/dpmi.h @@ -33,11 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "SDL.h" -#ifdef _WIN32 -#include "../../../Engine/src/windows/inttypes.h" -#else #include -#endif enum DPMI_Errors { diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/fx_man.h b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/fx_man.h index c8361716e3..9e74a381e4 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/fx_man.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/fx_man.h @@ -32,11 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __FX_MAN_H #include "sndcards.h" -#ifdef _WIN32 - #include "../../Engine/src/windows/inttypes.h" -#else - #include -#endif +#include typedef struct { diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/task_man.c b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/task_man.c index c39135fedb..c6e2cd6e9e 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/task_man.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/audiolib/task_man.c @@ -856,121 +856,3 @@ int TS_LockMemory } #endif - -/* -// Converts a hex byte to an integer - -static int btoi - ( - unsigned char bcd - ) - - { - unsigned b; - unsigned c; - unsigned d; - - b = bcd / 16; - c = bcd - b * 16; - d = b * 10 + c; - return( d ); - } - - -static void RestoreRealTimeClock - ( - void - ) - - { - int read; - int i; - int hr; - int min; - int sec; - int cent; - int yr; - int mo; - int day; - int year; - union REGS inregs; - - // Read Real Time Clock Time. - read = FALSE; - inregs.h.ah = 0x02; - for( i = 1; i <= 3; i++ ) - { - int386( 0x1A, &inregs, &inregs ); - if ( inregs.x.cflag == 0 ) - { - read = TRUE; - } - } - - if ( read ) - { - //and convert BCD to integer format - hr = btoi( inregs.h.ch ); - min = btoi( inregs.h.cl ); - sec = btoi( inregs.h.dh ); - - // Read Real Time Clock Date. - inregs.h.ah = 0x04; - int386( 0x1A, &inregs, &inregs ); - if ( inregs.x.cflag == 0 ) - { - //and convert BCD to integer format - cent = btoi( inregs.h.ch ); - yr = btoi( inregs.h.cl ); - mo = btoi( inregs.h.dh ); - day = btoi( inregs.h.dl ); - year = cent * 100 + yr; - - // Set System Time. - inregs.h.ch = hr; - inregs.h.cl = min; - inregs.h.dh = sec; - inregs.h.dl = 0; - inregs.h.ah = 0x2D; - int386( 0x21, &inregs, &inregs ); - - // Set System Date. - inregs.w.cx = year; - inregs.h.dh = mo; - inregs.h.dl = day; - inregs.h.ah = 0x2B; - int386( 0x21, &inregs, &inregs ); - } - } - } -*/ -/* - struct dostime_t time; - struct dosdate_t date; - - outp(0x70,0); - time.second=inp(0x71); - outp(0x70,2); - time.minute=inp(0x71); - outp(0x70,4); - time.hour=inp(0x71); - - outp(0x70,7); - date.day=inp(0x71); - outp(0x70,8); - date.month=inp(0x71); - outp(0x70,9); - date.year=inp(0x71); - - time.second=(time.second&0x0f)+((time.second>>4)*10); - time.minute=(time.minute&0x0f)+((time.minute>>4)*10); - time.hour=(time.hour&0x0f)+((time.hour>>4)*10); - - date.day=(date.day&0x0f)+((date.day>>4)*10); - date.month=(date.month&0x0f)+((date.month>>4)*10); - date.year=(date.year&0x0f)+((date.year>>4)*10); - - _dos_settime(&time); - _dos_setdate(&date); - -*/ diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/config.c b/apps/plugins/sdl/progs/duke3d/Game/src/config.c index 1649c40b07..f3d05d093c 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/config.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/config.c @@ -24,11 +24,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- -#if PLATFORM_DOS -#include -#include -#endif - #include #include #include @@ -698,18 +693,11 @@ void CONFIG_ReadSetup( void ) } SCRIPT_GetNumber( scripthandle, "Sound Setup", "FXDevice",&FXDevice); - #if !PLATFORM_DOS // reimplementation of ASS expects a "SoundScape". if (FXDevice != NumSoundCards) FXDevice = SoundScape; - #endif SCRIPT_GetNumber( scripthandle, "Sound Setup", "MusicDevice",&MusicDevice); - //#if !PLATFORM_DOS // reimplementation of ASS expects a "SoundScape". - // if (MusicDevice != NumSoundCards) - // MusicDevice = SoundScape; - //#endif - // FIX_00015: Forced NumVoices=8, NumChannels=2, NumBits=16, MixRate=44100, ScreenMode = x( // (ScreenMode has no meaning anymore) diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/cvar_defs.h b/apps/plugins/sdl/progs/duke3d/Game/src/cvar_defs.h index 054cb96914..1e6319c807 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/cvar_defs.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/cvar_defs.h @@ -1,11 +1,7 @@ #ifndef _CVARDEFS_H_ #define _CVARDEFS_H_ -#ifdef _WIN32 - #include "../../Engine/src/windows/inttypes.h" -#else - #include -#endif +#include void CVARDEFS_Init(); void CVARDEFS_Render(); diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/cvars.h b/apps/plugins/sdl/progs/duke3d/Game/src/cvars.h index 2ad341e58e..206e16a9c4 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/cvars.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/cvars.h @@ -4,11 +4,7 @@ #define REGCONVAR(varname, varhelp, variable, function) CVAR_RegisterCvar(varname, varhelp, &variable, &function) #define REGCONFUNC(varname, varhelp, function) CVAR_RegisterCvar(varname, varhelp, NULL, &function) -#ifdef _WIN32 - #include "../../Engine/src/windows/inttypes.h" -#else - #include -#endif +#include typedef void (*function_t) (void* binding); diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/duke3d.h b/apps/plugins/sdl/progs/duke3d/Game/src/duke3d.h index fee94d961a..02c88a42c7 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/duke3d.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/duke3d.h @@ -28,11 +28,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "platform.h" -#ifdef _WIN32 -#include "../../Engine/src/windows/inttypes.h" -#else #include -#endif #include #include @@ -50,26 +46,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #endif #endif -#if PLATFORM_DOS -#include -#include -#include -#define PATH_SEP_CHAR '\\' -#define PATH_SEP_STR "\\" -#endif - -#if PLATFORM_UNIX && !defined(ROCKBOX) -#include "dukeunix.h" -#endif - -#if PLATFORM_MACOSX -#include "dukeunix.h" -#endif - -#if PLATFORM_WIN32 -#include "dukewin.h" -#endif - #ifdef ROCKBOX #define PLATFORM_ROCKBOX 1 #endif @@ -524,11 +500,6 @@ extern struct player_struct ps[MAXPLAYERS]; extern struct player_orig po[MAXPLAYERS]; extern struct user_defs ud; -// ported build engine has this, too. --ryan. -#if PLATFORM_DOS -extern short int moustat; -#endif - extern short int global_random; extern int32_t scaredfallz; extern char buf[80]; //My own generic input buffer diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/dukerockbox.h b/apps/plugins/sdl/progs/duke3d/Game/src/dukerockbox.h index 9035336b8a..a5806b14b9 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/dukerockbox.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/dukerockbox.h @@ -32,25 +32,6 @@ #define O_BINARY 0 #endif -struct find_t -{ - DIR *dir; - char pattern[MAX_PATH]; - char name[MAX_PATH]; -}; -int _dos_findfirst(char *filename, int x, struct find_t *f); -int _dos_findnext(struct find_t *f); - -struct dosdate_t -{ - uint8_t day; - uint8_t month; - unsigned int year; - uint8_t dayofweek; -}; - -void _dos_getdate(struct dosdate_t *date); - #ifndef min #define min(x, y) ((x) < (y) ? (x) : (y)) #endif diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/dukeunix.h b/apps/plugins/sdl/progs/duke3d/Game/src/dukeunix.h deleted file mode 100644 index 451d174785..0000000000 --- a/apps/plugins/sdl/progs/duke3d/Game/src/dukeunix.h +++ /dev/null @@ -1,100 +0,0 @@ -// -// dukeunix.h -// Duke3D -// -// Created by fabien sanglard on 12-12-12. -// Copyright (c) 2012 fabien sanglard. All rights reserved. -// - -#ifndef Duke3D_dukeunix_h -#define Duke3D_dukeunix_h - - -#define cdecl -#define __far -#define __interrupt - - -//#define STUBBED(x) -#ifdef __SUNPRO_C -#define STUBBED(x) fprintf(stderr,"STUB: %s (??? %s:%d)\n",x,__FILE__,__LINE__) -#else -#define STUBBED(x) fprintf(stderr,"STUB: %s (%s, %s:%d)\n",x,__FUNCTION__,__FILE__,__LINE__) -#endif - -#define PATH_SEP_CHAR '/' -#define PATH_SEP_STR "/" -#define ROOTDIR "/" -#define CURDIR "./" - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -#include -#include -#include -#include -#include -#include - -struct find_t -{ - DIR *dir; - char pattern[MAX_PATH]; - char name[MAX_PATH]; -}; -int _dos_findfirst(char *filename, int x, struct find_t *f); -int _dos_findnext(struct find_t *f); - -struct dosdate_t -{ - uint8_t day; - uint8_t month; - unsigned int year; - uint8_t dayofweek; -}; - -void _dos_getdate(struct dosdate_t *date); - -#ifndef min -#define min(x, y) ((x) < (y) ? (x) : (y)) -#endif - -#ifndef max -#define max(x, y) ((x) > (y) ? (x) : (y)) -#endif - - - -#ifndef strcmpi -#define strcmpi(x, y) strcasecmp(x, y) -#endif - -#ifdef DC -#undef stderr -#undef stdout -#undef getchar -/* kos compat */ -#define stderr ((FILE*)2) -#define stdout ((FILE*)2) -#define Z_AvailHeap() ((10 * 1024) * 1024) -#else -// 64 megs should be enough for anybody. :) --ryan. -#define Z_AvailHeap() ((64 * 1024) * 1024) -#endif - -#define printchrasm(x,y,ch) printf("%c", (uint8_t ) (ch & 0xFF)) - -#ifdef __GNUC__ -#define GCC_PACK1_EXT __attribute__((packed,aligned(1))) -#endif - - -// FCS: Game.c features calls to mkdir without the proper flags. -// Giving all access is ugly but it is just game OK ! -#define mkdir(X) mkdir(X,0777) - -#define getch getchar - -#endif diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/dukewin.h b/apps/plugins/sdl/progs/duke3d/Game/src/dukewin.h deleted file mode 100644 index f35becb401..0000000000 --- a/apps/plugins/sdl/progs/duke3d/Game/src/dukewin.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef _INCL_DUKEWIN_H_ -#define _INCL_DUKEWIN_H_ 1 - -#ifndef _MSC_VER /* might need this. */ -typedef int32_t int32_t __int64; -#endif - -#pragma warning(disable:4761) - -#if USE_SDL -#include "SDL.h" -#endif - -#ifdef _DEBUG -#define STUBBED(x) printf("STUB: %s in %s:%d\n", x, __FILE__, __LINE__) -#else -#define STUBBED(x) -#endif - -#define PATH_SEP_CHAR '\\' -#define PATH_SEP_STR "\\" - -#include -#include -#include - -struct find_t -{ - int32_t handle; - struct _finddata_t data; - uint8_t name[MAX_PATH]; -}; -int _dos_findfirst(uint8_t *filename, int x, struct find_t *f); -int _dos_findnext(struct find_t *f); - -struct dosdate_t -{ - uint8_t day; - uint8_t month; - unsigned int year; - uint8_t dayofweek; -}; - -void _dos_getdate(struct dosdate_t *date); - -#ifndef min -#define min(x, y) ((x) < (y) ? (x) : (y)) -#endif - -#ifndef max -#define max(x, y) ((x) > (y) ? (x) : (y)) -#endif - -#ifdef FP_OFF -#undef FP_OFF -#endif -#define FP_OFF(x) ((int32_t) (x)) - -// 64 megs should be enough for anybody. :) --ryan. -#define Z_AvailHeap() ((64 * 1024) * 1024) - -#define printchrasm(x,y,ch) printf("%c", (uint8_t ) (ch & 0xFF)) - -#define cdecl - -#define open _open -#define O_BINARY _O_BINARY -#define O_RDONLY _O_RDONLY -#define O_WRONLY _O_WRONLY -#define O_RDWR _O_RDWR -#define O_TRUNC _O_TRUNC -#define O_CREAT _O_CREAT -#define S_IREAD _S_IREAD -#define S_IWRITE _S_IWRITE -#define S_IRDWR _S_IRDWR - -#define S_IRUSR S_IREAD -#define S_IWUSR S_IWRITE -#define S_IRGRP 0 -#define S_IWGRP 0 - -#define F_OK 0 - -#define HAVE_PRAGMA_PACK 1 - -#endif diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/game.c b/apps/plugins/sdl/progs/duke3d/Game/src/game.c index 0cb1d95b86..8b2c0e959f 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/game.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/game.c @@ -24,11 +24,7 @@ */ //------------------------------------------------------------------------- -#ifdef _WIN32 -#include -#else #include "SDL.h" -#endif #include "types.h" @@ -113,38 +109,12 @@ void pitch_test( void ); uint8_t restorepalette,screencapt,nomorelogohack; int sendmessagecommand = -1; -#if PLATFORM_DOS -task *TimerPtr=NULL; -#endif - extern int32_t lastvisinc; -// Build Engine port implements this. --ryan. -#if PLATFORM_DOS -static void timerhandler(task *unused) -{ - totalclock++; -} - -void inittimer() -{ - TimerPtr = TS_ScheduleTask( timerhandler,TICRATE, 1, NULL ); - TS_Dispatch(); -} - -void uninittimer(void) -{ - if (TimerPtr) - TS_Terminate( TimerPtr ); - TimerPtr = NULL; - TS_Shutdown(); -} -#else void timerhandler(void) { totalclock++; } -#endif int gametext(int x,int y,char *t,uint8_t s,short dabits) { @@ -2471,11 +2441,7 @@ GOTOHERE: if(true) { if(*t == ' ' && *(t+1) == 0) *t = 0; -#if PLATFORM_DOS // Is there a good reason for this? --ryan. - printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); -#else printf("\n%s\n",t); -#endif } // CTW END - MODIFICATION } @@ -7818,18 +7784,11 @@ void Startup(void) if(networkmode == 255) networkmode = 1; -#ifdef PLATFORM_DOS - puts("Checking music inits."); - MusicStartup(); - puts("Checking sound inits."); - SoundStartup(); -#else /* SBF - wasn't sure if swapping them would harm anything. */ puts("Checking sound inits."); SoundStartup(); puts("Checking music inits."); MusicStartup(); -#endif // AutoAim if(nHostForceDisableAutoaim) @@ -8019,64 +7978,6 @@ void getnames(void) const char* const baseDir="duke3d*.grp"; -#ifdef _WIN32 - -void findGRPToUse(uint8_t * groupfilefullpath) -{ - WIN32_FIND_DATA FindFileData; - HANDLE hFind = INVALID_HANDLE_VALUE; - int i=0,kbdKey ; - char groupfile[9][512]; - int grpID ; - - if(getGameDir()[0] != '\0') - { - sprintf(groupfilefullpath, "%s\\%s", getGameDir(), baseDir); - hFind = FindFirstFile(groupfilefullpath, &FindFileData); - if (hFind == INVALID_HANDLE_VALUE) - { - sprintf(groupfilefullpath, "%s", baseDir); - } - else - FindClose(hFind); - } - else - sprintf(groupfilefullpath, "%s", baseDir); - - printf("Searching '%d':\n\n",groupfilefullpath); - hFind = FindFirstFile(groupfilefullpath,&FindFileData); - - if ( hFind==INVALID_HANDLE_VALUE ) - Error(EXIT_SUCCESS, "Can't find '%s'\n", groupfilefullpath); - - do - { - i++; - sprintf(groupfile[i-1], "%s", FindFileData.cFileName); - printf("Found GRP #%d:\t%d Bytes\t %s \n", i, FindFileData.nFileSizeLow, groupfile[i-1]); - } while ( FindNextFile(hFind, &FindFileData) && i < 9 ); - - if(i==1) - grpID = 0; - else - { - printf("\n-> Choose a base GRP file from 1 to %c: ",'0' + i); - do - kbdKey = getch(); - while(kbdKey < '1' || kbdKey > ('0' + i)); - printf("%c\n", kbdKey); - grpID = groupfile[kbdKey-'1']; - - } - - FindClose(hFind); - if (strlen(getGameDir()) == 0) - sprintf(groupfilefullpath, "./%s", groupfile[grpID]); - else - sprintf(groupfilefullpath, "%s//%s", getGameDir(), groupfile[grpID]); -} - -#else int dukeGRP_Match(char* filename,int length) { @@ -8126,8 +8027,6 @@ void findGRPToUse(char * groupfilefullpath){ } } -#endif - static int load_duke3d_groupfile(void) { // FIX_00032: Added multi base GRP manager. Use duke3d*.grp to handle multiple grp. diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/gamedef.c b/apps/plugins/sdl/progs/duke3d/Game/src/gamedef.c index 52e2abaed6..af58c45deb 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/gamedef.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/gamedef.c @@ -1155,11 +1155,7 @@ uint8_t parsecommand(int readfromGRP) break; } } -#ifdef PLATFORM_UNIX volume_names[j][i] = '\0'; -#else - volume_names[j][i-1] = '\0'; -#endif return 0; case 108: scriptptr--; @@ -1182,11 +1178,7 @@ uint8_t parsecommand(int readfromGRP) break; } } -#if defined(PLATFORM_UNIX) || defined(PLATFORM_ROCKBOX) skill_names[j][i] = '\0'; -#else - skill_names[j][i-1] = '\0'; -#endif return 0; case 0: @@ -1212,11 +1204,7 @@ uint8_t parsecommand(int readfromGRP) break; } } -#if defined(PLATFORM_UNIX) || defined(PLATFORM_ROCKBOX) level_names[j*11+k][i] = '\0'; -#else - level_names[j*11+k][i-1] = '\0'; -#endif while( *textptr == ' ' ) textptr++; partime[j*11+k] = @@ -1247,11 +1235,7 @@ uint8_t parsecommand(int readfromGRP) break; } } -#ifdef PLATFORM_UNIX level_names[j*11+k][i] = '\0'; -#else - level_names[j*11+k][i-1] = '\0'; -#endif return 0; case 79: @@ -1570,11 +1554,7 @@ void loadefs(char *filenam, char *mptr, int readfromGRP) //ud.conCRC[0] = crc32_update((uint8_t *)textptr, fs, ud.conCRC[0]); } -#ifdef PLATFORM_UNIX textptr[fs - 1] = 0; -#else - textptr[fs - 2] = 0; -#endif clearbuf(actorscrptr,MAXSPRITES,0L); clearbufbyte(actortype,MAXSPRITES,0L); diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/global.c b/apps/plugins/sdl/progs/duke3d/Game/src/global.c index 57c561edd6..b0f4442d32 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/global.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/global.c @@ -76,11 +76,6 @@ int32_t gc,neartaghitdist,lockclock,max_player_health,max_armour_amount,max_ammo struct weaponhit hittype[MAXSPRITES]; short spriteq[1024],spriteqloc,spriteqamount=64; -// ported build engine has this, too. --ryan. -#if PLATFORM_DOS -short moustat = 0; -#endif - struct animwalltype animwall[MAXANIMWALLS]; short numanimwalls; int32_t *animateptr[MAXANIMATES], animategoal[MAXANIMATES], animatevel[MAXANIMATES], animatecnt; @@ -232,7 +227,6 @@ int32_t *curipos[MAXINTERPOLATIONS]; void FixFilePath(char *filename) { -#if PLATFORM_UNIX || PLATFORM_ROCKBOX uint8_t *ptr; uint8_t *lastsep = filename; @@ -304,74 +298,8 @@ void FixFilePath(char *filename) return; } } -#endif } - -#if PLATFORM_DOS - /* no-op. */ - -#elif PLATFORM_WIN32 -int _dos_findfirst(uint8_t *filename, int x, struct find_t *f) -{ - int32_t rc = _findfirst(filename, &f->data); - f->handle = rc; - if (rc != -1) - { - strncpy(f->name, f->data.name, sizeof (f->name) - 1); - f->name[sizeof (f->name) - 1] = '\0'; - return(0); - } - return(1); -} - -int _dos_findnext(struct find_t *f) -{ - int rc = 0; - if (f->handle == -1) - return(1); /* invalid handle. */ - - rc = _findnext(f->handle, &f->data); - if (rc == -1) - { - _findclose(f->handle); - f->handle = -1; - return(1); - } - - strncpy(f->name, f->data.name, sizeof (f->name) - 1); - f->name[sizeof (f->name) - 1] = '\0'; - return(0); -} - -#elif defined(PLATFORM_UNIX) || defined(PLATFORM_MACOSX) || defined(PLATFORM_ROCKBOX) -int _dos_findfirst(char *filename, int x, struct find_t *f) -{ - char *ptr; - - if (strlen(filename) >= sizeof (f->pattern)) - return(1); - - strcpy(f->pattern, filename); - FixFilePath(f->pattern); - ptr = strrchr(f->pattern, PATH_SEP_CHAR); - - if (ptr == NULL) - { - ptr = filename; - f->dir = opendir(CURDIR); - } - else - { - *ptr = '\0'; - f->dir = opendir(f->pattern); - memmove(f->pattern, ptr + 1, strlen(ptr + 1) + 1); - } - - return(_dos_findnext(f)); -} - - static int check_pattern_nocase(const char *x, const char *y) { if ((x == NULL) || (y == NULL)) @@ -409,53 +337,6 @@ static int check_pattern_nocase(const char *x, const char *y) return(*x == *y); /* it's a match (both should be EOS). */ } -int _dos_findnext(struct find_t *f) -{ - struct dirent *dent; - - if (f->dir == NULL) - return(1); /* no such dir or we're just done searching. */ - - while ((dent = readdir(f->dir)) != NULL) - { - if (check_pattern_nocase(f->pattern, dent->d_name)) - { - if (strlen(dent->d_name) < sizeof (f->name)) - { - strcpy(f->name, dent->d_name); - return(0); /* match. */ - } - } - } - - closedir(f->dir); - f->dir = NULL; - return(1); /* no match in whole directory. */ -} -#else -#error please define for your platform. -#endif - - -#if !PLATFORM_DOS -void _dos_getdate(struct dosdate_t *date) -{ - time_t curtime = time(NULL); - - if (date == NULL) { - return; - } - - memset(date, 0, sizeof(struct dosdate_t)); - - date->day = 1; - date->month = 1; - date->year = 1970; - date->dayofweek = 4; -} -#endif - - int FindDistance2D(int ix, int iy) { int t; @@ -560,11 +441,7 @@ int32 SafeOpenAppend (const char *_filename, int32 filetype) filename[sizeof (filename) - 1] = '\0'; FixFilePath(filename); -#if (defined PLATFORM_WIN32) - handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_APPEND ); -#else handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_APPEND , 0666); -#endif if (handle == -1) Error (EXIT_FAILURE, "Error opening for append %s: %s",filename,strerror(errno)); @@ -579,11 +456,7 @@ boolean SafeFileExists ( const char * _filename ) filename[sizeof (filename) - 1] = '\0'; FixFilePath(filename); -#if( defined PLATFORM_WIN32) - return(access(filename, 6) == 0); -#else - return(rb->file_exists(filename)); -#endif + return(rb->file_exists(filename)); } @@ -595,12 +468,8 @@ int32 SafeOpenWrite (const char *_filename, int32 filetype) filename[sizeof (filename) - 1] = '\0'; FixFilePath(filename); -#if (defined PLATFORM_WIN32) - handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC ); -#else handle = open(filename,O_RDWR | O_BINARY | O_CREAT | O_TRUNC , 0666); -#endif if (handle == -1) Error (EXIT_FAILURE, "Error opening %s: %s",filename,strerror(errno)); @@ -783,7 +652,6 @@ void SwapIntelShortArray(short *s, int num) Stolen for Duke3D, too. */ -#if PLATFORM_UNIX uint8_t *strlwr(uint8_t *s) { uint8_t *p = s; @@ -858,13 +726,11 @@ uint8_t *ultoa(uint32_t value, uint8_t *string, int radix) return string; } -#endif char ApogeePath[256]; int setup_homedir (void) { -#if PLATFORM_UNIX int err; snprintf (ApogeePath, sizeof (ApogeePath), "%s/.duke3d/", getenv ("HOME")); @@ -877,9 +743,6 @@ int setup_homedir (void) strerror (errno)); return -1; } -#else - sprintf(ApogeePath, ".%s", PATH_SEP_STR); -#endif return 0; } diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/global.h b/apps/plugins/sdl/progs/duke3d/Game/src/global.h index e0be16f500..ab7d6eb634 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/global.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/global.h @@ -18,23 +18,11 @@ int FindDistance3D(int ix, int iy, int iz); void Shutdown(void); #ifndef LITTLE_ENDIAN - #ifdef __APPLE__ - #else - #define LITTLE_ENDIAN 1234 - #endif + #define LITTLE_ENDIAN 1234 #endif #ifndef BIG_ENDIAN - #ifdef __APPLE__ - #else - #define BIG_ENDIAN 4321 - #endif -#endif - -#if PLATFORM_WIN32 -#ifndef BYTE_ORDER -#define BYTE_ORDER LITTLE_ENDIAN -#endif + #define BIG_ENDIAN 4321 #endif #ifdef ROCKBOX @@ -45,15 +33,6 @@ void Shutdown(void); #endif #endif -#ifdef __APPLE__ -#if __powerpc__ -#define BYTE_ORDER BIG_ENDIAN -#else -// Defined in endian.h -// #define BYTE_ORDER LITTLE_ENDIAN -#endif -#endif - #ifndef BYTE_ORDER #error Please define your platform. #endif diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/menues.c b/apps/plugins/sdl/progs/duke3d/Game/src/menues.c index 3585600f43..66ce4123bf 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/menues.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/menues.c @@ -1245,83 +1245,10 @@ void dispnames(void) } - -// This is the same thing as was in build.c ... -// We DO have a _dos_findfirst implementation now...maybe use that instead? -// --ryan. -#if ORIGINAL_DUKE3D_GETFILENAMES -int getfilenames(uint8_t kind[6]) -{ - short type; - struct find_t fileinfo; - - if (strcmp(kind,"SUBD") == 0) - { - strcpy(kind,"*.*"); - if (_dos_findfirst(kind,_A_SUBDIR,&fileinfo) != 0) - return(-1); - type = 1; - } - else - { - if (_dos_findfirst(kind,_A_NORMAL,&fileinfo) != 0) - return(-1); - type = 0; - } - do - { - if ((type == 0) || ((fileinfo.attrib&16) > 0)) - if ((fileinfo.name[0] != '.') || (fileinfo.name[1] != 0)) - { - strcpy(menuname[menunamecnt],fileinfo.name); - menuname[menunamecnt][16] = type; - menunamecnt++; - } - } - while (_dos_findnext(&fileinfo) == 0); - - return(0); -} - -#else - int getfilenames(char kind[6]) { -/* !!! FIXME: Visual C? */ -#if (defined __WATCOMC__) - short type; - struct find_t fileinfo; - - if (strcmp(kind,"SUBD") == 0) - { - strcpy(kind,"*.*"); - if (_dos_findfirst(kind,_A_SUBDIR,&fileinfo) != 0) - return(-1); - type = 1; - } - else - { - if (_dos_findfirst(kind,_A_NORMAL,&fileinfo) != 0) - return(-1); - type = 0; - } - do - { - if ((type == 0) || ((fileinfo.attrib&16) > 0)) - if ((fileinfo.name[0] != '.') || (fileinfo.name[1] != 0)) - { - strcpy(menuname[menunamecnt],fileinfo.name); - menuname[menunamecnt][16] = type; - menunamecnt++; - } - } - while (_dos_findnext(&fileinfo) == 0); - -#elif (defined PLATFORM_UNIX) - DIR *dir; struct dirent *dent; - struct stat statbuf; int add_this; uint8_t *ptr = NULL; int len = 0; @@ -1330,7 +1257,7 @@ int getfilenames(char kind[6]) if (strcmp(kind,"SUBD") == 0) subdirs = 1; - dir = opendir(getGamedir()); + dir = opendir(getGameDir()); if (dir == NULL) return(-1); @@ -1340,46 +1267,39 @@ int getfilenames(char kind[6]) dent = readdir(dir); if (dent != NULL) { - if (stat(dent->d_name, &statbuf) == 0) - { - if (subdirs) - { - if (S_ISDIR(statbuf.st_mode)) - add_this = 1; - } /* if */ - else - { - /* need to expand support if this assertion ever fails. */ - assert(stricmp(kind, "*.MAP") == 0); - len = strlen(dent->d_name); - if (len >= 5) - { - ptr = ((uint8_t *) dent->d_name) + len; - ptr += strlen(ptr) - 4; - if (stricmp(ptr, ".MAP") == 0) - add_this = 1; - } /* if */ - } /* else */ + if (subdirs) + { + if (rb->dir_exists(dent->d_name)) + add_this = 1; + } /* if */ + else + { + /* need to expand support if this assertion ever fails. */ + assert(stricmp(kind, "*.MAP") == 0); + len = strlen(dent->d_name); + if (len >= 5) + { + ptr = ((uint8_t *) dent->d_name) + len; + ptr += strlen(ptr) - 4; + if (stricmp(ptr, ".MAP") == 0) + add_this = 1; + } /* if */ + } /* else */ - if (add_this) - { - strcpy(menuname[menunamecnt],dent->d_name); - menuname[menunamecnt][16] = subdirs; - menunamecnt++; - } /* if */ - } /* if */ + if (add_this) + { + strcpy(menuname[menunamecnt],dent->d_name); + menuname[menunamecnt][16] = subdirs; + menunamecnt++; + } /* if */ } /* if */ } while (dent != NULL); closedir(dir); -#endif return(0); } -#endif - - void sortfilenames() { uint8_t sortbuffer[17]; diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/sounds.c b/apps/plugins/sdl/progs/duke3d/Game/src/sounds.c index 0e3c8f6fa9..14d705bb5c 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/sounds.c +++ b/apps/plugins/sdl/progs/duke3d/Game/src/sounds.c @@ -24,10 +24,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms */ //------------------------------------------------------------------------- -#if PLATFORM_DOS -#include -#endif - #include #include #include "../../Game/src/types.h" diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/types.h b/apps/plugins/sdl/progs/duke3d/Game/src/types.h index 017c851a18..93d6f80c86 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/types.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/types.h @@ -27,11 +27,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #ifndef _types_public #define _types_public -#ifdef _WIN32 - #include "../../Engine/src/windows/inttypes.h" -#else - #include -#endif +#include #ifdef __cplusplus extern "C" { diff --git a/apps/plugins/sdl/progs/duke3d/Game/src/util_lib.h b/apps/plugins/sdl/progs/duke3d/Game/src/util_lib.h index bf9e22d2a6..6519331b77 100644 --- a/apps/plugins/sdl/progs/duke3d/Game/src/util_lib.h +++ b/apps/plugins/sdl/progs/duke3d/Game/src/util_lib.h @@ -30,11 +30,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms // //*************************************************************************** -#ifdef _WIN32 - #include "../../Engine/src/windows/inttypes.h" -#else - #include -#endif +#include #ifndef _util_lib_public #define _util_lib_public diff --git a/apps/plugins/sdl/progs/quake/cl_parse.c b/apps/plugins/sdl/progs/quake/cl_parse.c index c79ca47545..6a2856709e 100644 --- a/apps/plugins/sdl/progs/quake/cl_parse.c +++ b/apps/plugins/sdl/progs/quake/cl_parse.c @@ -884,16 +884,10 @@ void CL_ParseServerMessage (void) if (cl.paused) { CDAudio_Pause (); -#ifdef _WIN32 - VID_HandlePause (true); -#endif } else { CDAudio_Resume (); -#ifdef _WIN32 - VID_HandlePause (false); -#endif } } break; diff --git a/apps/plugins/sdl/progs/quake/common.c b/apps/plugins/sdl/progs/quake/common.c index 5191af8c36..881c01e22e 100644 --- a/apps/plugins/sdl/progs/quake/common.c +++ b/apps/plugins/sdl/progs/quake/common.c @@ -1508,14 +1508,7 @@ int COM_FindFile (char *filename, int *handle, FILE **file) strcpy (cachepath, netpath); else { -#if defined(_WIN32) - if ((strlen(netpath) < 2) || (netpath[1] != ':')) - sprintf (cachepath,"%s%s", com_cachedir, netpath); - else - sprintf (cachepath,"%s%s", com_cachedir, netpath+2); -#else sprintf (cachepath,"%s/%s", com_cachedir, netpath); -#endif cachetime = Sys_FileTime (cachepath); diff --git a/apps/plugins/sdl/progs/quake/host.c b/apps/plugins/sdl/progs/quake/host.c index 9a5f7c29d6..6e30503d77 100644 --- a/apps/plugins/sdl/progs/quake/host.c +++ b/apps/plugins/sdl/progs/quake/host.c @@ -896,32 +896,22 @@ void Host_Init (quakeparms_t *parms) if (!host_colormap) Sys_Error ("Couldn't load gfx/colormap.lmp"); -#ifndef _WIN32 // on non win32, mouse comes before video for security reasons IN_Init (); -#endif VID_Init (host_basepal); Draw_Init (); SCR_Init (); R_Init (); -#ifndef _WIN32 - // on Win32, sound initialization has to come before video initialization, so we - // can put up a popup if the sound hardware is in use S_Init (); -#else #ifdef GLQUAKE // FIXME: doesn't use the new one-window approach yet S_Init (); #endif -#endif // _WIN32 CDAudio_Init (); Sbar_Init (); CL_Init (); -#ifdef _WIN32 // on non win32, mouse comes before video for security reasons - IN_Init (); -#endif } Cbuf_InsertText ("exec quake.rc\n"); diff --git a/apps/plugins/sdl/progs/quake/mathlib.c b/apps/plugins/sdl/progs/quake/mathlib.c index ddd5435089..a949a39a51 100644 --- a/apps/plugins/sdl/progs/quake/mathlib.c +++ b/apps/plugins/sdl/progs/quake/mathlib.c @@ -85,10 +85,6 @@ void PerpendicularVector( vec3_t dst, const vec3_t src ) VectorNormalizeNoRet( dst ); } -#ifdef _WIN32 -#pragma optimize( "", off ) -#endif - void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ) { @@ -145,10 +141,6 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, } } -#ifdef _WIN32 -#pragma optimize( "", on ) -#endif - /*-----------------------------------------------------------------*/ diff --git a/apps/plugins/sdl/progs/quake/menu.c b/apps/plugins/sdl/progs/quake/menu.c index 8c67c8672d..2a3229559b 100644 --- a/apps/plugins/sdl/progs/quake/menu.c +++ b/apps/plugins/sdl/progs/quake/menu.c @@ -19,10 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "quakedef.h" -#ifdef _WIN32 -#include "winquake.h" -#endif - void (*vid_menudrawfn)(void); void (*vid_menukeyfn)(int key); @@ -913,11 +909,7 @@ void M_Net_Draw (void) } else { -#ifdef _WIN32 - p = NULL; -#else p = Draw_CachePic ("gfx/dim_modm.lmp"); -#endif } if (p) @@ -931,11 +923,7 @@ void M_Net_Draw (void) } else { -#ifdef _WIN32 - p = NULL; -#else p = Draw_CachePic ("gfx/dim_drct.lmp"); -#endif } if (p) @@ -1036,12 +1024,7 @@ again: //============================================================================= /* OPTIONS MENU */ -#ifdef _WIN32 -#define OPTIONS_ITEMS 14 -#else #define OPTIONS_ITEMS 13 -#endif - #define SLIDER_RANGE 10 int options_cursor; @@ -1051,13 +1034,6 @@ void M_Menu_Options_f (void) key_dest = key_menu; m_state = m_options; m_entersound = true; - -#ifdef _WIN32 - if ((options_cursor == 13) && (modestate != MS_WINDOWED)) - { - options_cursor = 0; - } -#endif } @@ -1092,11 +1068,7 @@ void M_AdjustSliders (int dir) Cvar_SetValue ("sensitivity", sensitivity.value); break; case 6: // music volume -#ifdef _WIN32 - bgmvolume.value += dir * 1.0; -#else bgmvolume.value += dir * 0.1; -#endif if (bgmvolume.value < 0) bgmvolume.value = 0; if (bgmvolume.value > 1) @@ -1136,12 +1108,6 @@ void M_AdjustSliders (int dir) case 11: // lookstrafe Cvar_SetValue ("lookstrafe", !lookstrafe.value); break; - -#ifdef _WIN32 - case 13: // _windowed_mouse - Cvar_SetValue ("_windowed_mouse", !_windowed_mouse.value); - break; -#endif } } @@ -1223,14 +1189,6 @@ void M_Options_Draw (void) if (vid_menudrawfn) M_Print (16, 128, " Video Options"); -#ifdef _WIN32 - if (modestate == MS_WINDOWED) - { - M_Print (16, 136, " Use Mouse"); - M_DrawCheckbox (220, 136, _windowed_mouse.value); - } -#endif - // cursor M_DrawCharacter (200, 32 + options_cursor*8, 12+((int)(realtime*4)&1)); } @@ -1297,16 +1255,6 @@ void M_Options_Key (int k) else options_cursor = 0; } - -#ifdef _WIN32 - if ((options_cursor == 13) && (modestate != MS_WINDOWED)) - { - if (k == K_UPARROW) - options_cursor = 12; - else - options_cursor = 0; - } -#endif } //============================================================================= @@ -1582,7 +1530,6 @@ int msgNumber; int m_quit_prevstate; qboolean wasInMenus; -#ifndef _WIN32 char *quitMessage [] = { /* .........1.........2.... */ @@ -1626,7 +1573,6 @@ char *quitMessage [] = " for you next time! ", " " }; -#endif void M_Menu_Quit_f (void) { @@ -1684,36 +1630,11 @@ void M_Quit_Draw (void) m_state = m_quit; } -#ifdef _WIN32 - M_DrawTextBox (0, 0, 38, 23); - M_PrintWhite (16, 12, " Quake version 1.09 by id Software\n\n"); - M_PrintWhite (16, 28, "Programming Art \n"); - M_Print (16, 36, " John Carmack Adrian Carmack\n"); - M_Print (16, 44, " Michael Abrash Kevin Cloud\n"); - M_Print (16, 52, " John Cash Paul Steed\n"); - M_Print (16, 60, " Dave 'Zoid' Kirsch\n"); - M_PrintWhite (16, 68, "Design Biz\n"); - M_Print (16, 76, " John Romero Jay Wilbur\n"); - M_Print (16, 84, " Sandy Petersen Mike Wilson\n"); - M_Print (16, 92, " American McGee Donna Jackson\n"); - M_Print (16, 100, " Tim Willits Todd Hollenshead\n"); - M_PrintWhite (16, 108, "Support Projects\n"); - M_Print (16, 116, " Barrett Alexander Shawn Green\n"); - M_PrintWhite (16, 124, "Sound Effects\n"); - M_Print (16, 132, " Trent Reznor and Nine Inch Nails\n\n"); - M_PrintWhite (16, 140, "Quake is a trademark of Id Software,\n"); - M_PrintWhite (16, 148, "inc., (c)1996 Id Software, inc. All\n"); - M_PrintWhite (16, 156, "rights reserved. NIN logo is a\n"); - M_PrintWhite (16, 164, "registered trademark licensed to\n"); - M_PrintWhite (16, 172, "Nothing Interactive, Inc. All rights\n"); - M_PrintWhite (16, 180, "reserved. Press y to exit\n"); -#else M_DrawTextBox (56, 76, 24, 4); M_Print (64, 84, quitMessage[msgNumber*4+0]); M_Print (64, 92, quitMessage[msgNumber*4+1]); M_Print (64, 100, quitMessage[msgNumber*4+2]); M_Print (64, 108, quitMessage[msgNumber*4+3]); -#endif } //============================================================================= diff --git a/apps/plugins/sdl/progs/quake/net.h b/apps/plugins/sdl/progs/quake/net.h index af461256b6..813472c0c6 100644 --- a/apps/plugins/sdl/progs/quake/net.h +++ b/apps/plugins/sdl/progs/quake/net.h @@ -238,7 +238,7 @@ typedef struct extern int hostCacheCount; extern hostcache_t hostcache[HOSTCACHESIZE]; -#if !defined(_WIN32 ) && !defined (__linux__) && !defined (__sun__) +#if !defined (__linux__) && !defined (__sun__) #ifndef htonl extern unsigned long htonl (unsigned long hostlong); #endif diff --git a/apps/plugins/sdl/progs/quake/net_dgrm.c b/apps/plugins/sdl/progs/quake/net_dgrm.c index a293b77b9f..bead46f8d1 100644 --- a/apps/plugins/sdl/progs/quake/net_dgrm.c +++ b/apps/plugins/sdl/progs/quake/net_dgrm.c @@ -23,9 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define BAN_TEST #ifdef BAN_TEST -#if defined(_WIN32) -#include -#elif defined (NeXT) +#if defined (NeXT) #include #include #else diff --git a/apps/plugins/sdl/progs/quake/quakeasm.h b/apps/plugins/sdl/progs/quake/quakeasm.h index 303853944e..fe58bfeb95 100644 --- a/apps/plugins/sdl/progs/quake/quakeasm.h +++ b/apps/plugins/sdl/progs/quake/quakeasm.h @@ -23,14 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //#define GLQUAKE 1 -#if defined(_WIN32) && !defined(WINDED) - -#if defined(_M_IX86) -#define __i386__ 1 -#endif - -#endif - #if defined(__i386__) && defined(USE_ASM) #define id386 1 #else diff --git a/apps/plugins/sdl/progs/quake/quakedef.h b/apps/plugins/sdl/progs/quake/quakedef.h index e676b7c9e7..b16d9b72f3 100644 --- a/apps/plugins/sdl/progs/quake/quakedef.h +++ b/apps/plugins/sdl/progs/quake/quakedef.h @@ -43,22 +43,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define GAMENAME "id1" #endif -#if defined(_WIN32) && !defined(WINDED) - -#if defined(_M_IX86) -#define __i386__ 1 -#endif - -void VID_LockBuffer (void); -void VID_UnlockBuffer (void); - -#else - #define VID_LockBuffer() #define VID_UnlockBuffer() -#endif - #if defined(__i386__) && defined(USE_ASM) #define id386 1 #else diff --git a/apps/plugins/sdl/progs/quake/snd_dma.c b/apps/plugins/sdl/progs/quake/snd_dma.c index 4c42f32d49..3789381552 100644 --- a/apps/plugins/sdl/progs/quake/snd_dma.c +++ b/apps/plugins/sdl/progs/quake/snd_dma.c @@ -21,10 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -#ifdef _WIN32 -#include "winquake.h" -#endif - void S_Play(void); void S_PlayVol(void); void S_SoundList(void); @@ -148,9 +144,7 @@ void S_Startup (void) if (!rc) { -#ifndef _WIN32 Con_Printf("S_Startup: SNDDMA_Init failed.\n"); -#endif sound_started = 0; return; } @@ -561,11 +555,7 @@ void S_ClearBuffer (void) { int clear; -#ifdef _WIN32 - if (!sound_started || !shm || (!shm->buffer && !pDSBuf)) -#else if (!sound_started || !shm || !shm->buffer) -#endif return; if (shm->samplebits == 8) @@ -573,43 +563,7 @@ void S_ClearBuffer (void) else clear = 0; -#ifdef _WIN32 - if (pDSBuf) - { - DWORD dwSize; - DWORD *pData; - int reps; - HRESULT hresult; - - reps = 0; - - while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pData, &dwSize, NULL, NULL, 0)) != DS_OK) - { - if (hresult != DSERR_BUFFERLOST) - { - Con_Printf ("S_ClearBuffer: DS::Lock Sound Buffer Failed\n"); - S_Shutdown (); - return; - } - - if (++reps > 10000) - { - Con_Printf ("S_ClearBuffer: DS: couldn't restore buffer\n"); - S_Shutdown (); - return; - } - } - - Q_memset(pData, clear, shm->samples * shm->samplebits/8); - - pDSBuf->lpVtbl->Unlock(pDSBuf, pData, dwSize, NULL, 0); - - } - else -#endif - { - Q_memset(shm->buffer, clear, shm->samples * shm->samplebits/8); - } + Q_memset(shm->buffer, clear, shm->samples * shm->samplebits/8); } @@ -844,11 +798,6 @@ void GetSoundtime(void) void S_ExtraUpdate (void) { - -#ifdef _WIN32 - IN_Accumulate (); -#endif - if (snd_noextraupdate.value) return; // don't pollute timings S_Update_(); @@ -880,25 +829,6 @@ void S_Update_(void) if (endtime - soundtime > samps) endtime = soundtime + samps; -#ifdef _WIN32 -// if the buffer was lost or stopped, restore it and/or restart it - { - DWORD dwStatus; - - if (pDSBuf) - { - if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DD_OK) - Con_Printf ("Couldn't get sound buffer status\n"); - - if (dwStatus & DSBSTATUS_BUFFERLOST) - pDSBuf->lpVtbl->Restore (pDSBuf); - - if (!(dwStatus & DSBSTATUS_PLAYING)) - pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING); - } - } -#endif - S_PaintChannels (endtime); SNDDMA_Submit (); diff --git a/apps/plugins/sdl/progs/quake/vid.h b/apps/plugins/sdl/progs/quake/vid.h index 1708ba825f..73c2ac7b4c 100644 --- a/apps/plugins/sdl/progs/quake/vid.h +++ b/apps/plugins/sdl/progs/quake/vid.h @@ -79,7 +79,3 @@ void VID_Update (vrect_t *rects); int VID_SetMode (int modenum, unsigned char *palette); // sets the mode; only used by the Quake engine for resetting to mode 0 (the // base mode) on memory allocation failures - -void VID_HandlePause (qboolean pause); -// called only on Win32, when pause happens, so the mouse can be released - diff --git a/apps/plugins/sdl/progs/quake/winquake.h b/apps/plugins/sdl/progs/quake/winquake.h deleted file mode 100644 index a956984fe6..0000000000 --- a/apps/plugins/sdl/progs/quake/winquake.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -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. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -// winquake.h: Win32-specific Quake header file - -#pragma warning( disable : 4229 ) // mgraph gets this - -#include -#define WM_MOUSEWHEEL 0x020A - -#ifndef SERVERONLY -#include -#include -#ifndef GLQUAKE -#include -#endif -#endif - -extern HINSTANCE global_hInstance; -extern int global_nCmdShow; - -#ifndef SERVERONLY - -extern LPDIRECTDRAW lpDD; -extern qboolean DDActive; -extern LPDIRECTDRAWSURFACE lpPrimary; -extern LPDIRECTDRAWSURFACE lpFrontBuffer; -extern LPDIRECTDRAWSURFACE lpBackBuffer; -extern LPDIRECTDRAWPALETTE lpDDPal; -extern LPDIRECTSOUND pDS; -extern LPDIRECTSOUNDBUFFER pDSBuf; - -extern DWORD gSndBufSize; -//#define SNDBUFSIZE 65536 - -void VID_LockBuffer (void); -void VID_UnlockBuffer (void); - -#endif - -typedef int modestate_t; -enum {MS_WINDOWED, MS_FULLSCREEN, MS_FULLDIB, MS_UNINIT}; - -extern modestate_t modestate; - -extern HWND mainwindow; -extern qboolean ActiveApp, Minimized; - -extern qboolean WinNT; - -int VID_ForceUnlockedAndReturnState (void); -void VID_ForceLockState (int lk); - -void IN_ShowMouse (void); -void IN_DeactivateMouse (void); -void IN_HideMouse (void); -void IN_ActivateMouse (void); -void IN_RestoreOriginalMouseState (void); -void IN_SetQuakeMouseState (void); -void IN_MouseEvent (int mstate); - -extern qboolean winsock_lib_initialized; - -extern cvar_t _windowed_mouse; - -extern int window_center_x, window_center_y; -extern RECT window_rect; - -extern qboolean mouseinitialized; -extern HWND hwnd_dialog; - -extern HANDLE hinput, houtput; - -void IN_UpdateClipCursor (void); -void CenterWindow(HWND hWndCenter, int width, int height, BOOL lefttopjustify); - -void S_BlockSound (void); -void S_UnblockSound (void); - -void VID_SetDefaultMode (void); - -int (PASCAL FAR *pWSAStartup)(WORD wVersionRequired, LPWSADATA lpWSAData); -int (PASCAL FAR *pWSACleanup)(void); -int (PASCAL FAR *pWSAGetLastError)(void); -SOCKET (PASCAL FAR *psocket)(int af, int type, int protocol); -int (PASCAL FAR *pioctlsocket)(SOCKET s, long cmd, u_long FAR *argp); -int (PASCAL FAR *psetsockopt)(SOCKET s, int level, int optname, - const char FAR * optval, int optlen); -int (PASCAL FAR *precvfrom)(SOCKET s, char FAR * buf, int len, int flags, - struct sockaddr FAR *from, int FAR * fromlen); -int (PASCAL FAR *psendto)(SOCKET s, const char FAR * buf, int len, int flags, - const struct sockaddr FAR *to, int tolen); -int (PASCAL FAR *pclosesocket)(SOCKET s); -int (PASCAL FAR *pgethostname)(char FAR * name, int namelen); -struct hostent FAR * (PASCAL FAR *pgethostbyname)(const char FAR * name); -struct hostent FAR * (PASCAL FAR *pgethostbyaddr)(const char FAR * addr, - int len, int type); -int (PASCAL FAR *pgetsockname)(SOCKET s, struct sockaddr FAR *name, - int FAR * namelen); diff --git a/apps/plugins/sdl/progs/wolf3d/sdl_winmain.c b/apps/plugins/sdl/progs/wolf3d/sdl_winmain.c deleted file mode 100644 index 366616d5ff..0000000000 --- a/apps/plugins/sdl/progs/wolf3d/sdl_winmain.c +++ /dev/null @@ -1,378 +0,0 @@ -#ifdef _WIN32 - -/* - SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98 - - Modified to write stdout/stderr to a message box at shutdown by Ripper 2007-12-27 - - The WinMain function -- calls your program's main() function -*/ - -#include -#include - -#define WIN32_LEAN_AND_MEAN -#include - -#ifdef _WIN32_WCE -# define DIR_SEPERATOR TEXT("\\") -# undef _getcwd -# define _getcwd(str,len) wcscpy(str,TEXT("")) -# define setbuf(f,b) -# define setvbuf(w,x,y,z) -# define fopen _wfopen -# define freopen _wfreopen -# define remove(x) DeleteFile(x) -#else -# define DIR_SEPERATOR TEXT("/") -# include -#endif - -/* Include the SDL main definition header */ -#include "SDL.h" -#include "SDL_main.h" - -#ifdef main -# ifndef _WIN32_WCE_EMULATION -# undef main -# endif /* _WIN32_WCE_EMULATION */ -#endif /* main */ - -/* The standard output files */ -#define STDOUT_FILE TEXT("stdout.txt") -#define STDERR_FILE TEXT("stderr.txt") - -#ifndef NO_STDIO_REDIRECT -# ifdef _WIN32_WCE - static wchar_t stdoutPath[MAX_PATH]; - static wchar_t stderrPath[MAX_PATH]; -# else - static char stdoutPath[MAX_PATH]; - static char stderrPath[MAX_PATH]; -# endif -#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')) -#endif /* _WIN32_WCE < 300 */ - -/* Parse a command line buffer into arguments */ -static int ParseCommandLine(char *cmdline, char **argv) -{ - char *bufp; - int argc; - - argc = 0; - for ( bufp = cmdline; *bufp; ) { - /* Skip leading whitespace */ - while ( isspace(*bufp) ) { - ++bufp; - } - /* Skip over argument */ - if ( *bufp == '"' ) { - ++bufp; - if ( *bufp ) { - if ( argv ) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while ( *bufp && (*bufp != '"') ) { - ++bufp; - } - } else { - if ( *bufp ) { - if ( argv ) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while ( *bufp && ! isspace(*bufp) ) { - ++bufp; - } - } - if ( *bufp ) { - if ( argv ) { - *bufp = '\0'; - } - ++bufp; - } - } - if ( argv ) { - argv[argc] = NULL; - } - return(argc); -} - -/* Show an error message */ -static void ShowError(const char *title, const char *message) -{ -/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ -#ifdef USE_MESSAGEBOX - MessageBox(NULL, message, title, MB_ICONEXCLAMATION|MB_OK); -#else - fprintf(stderr, "%s: %s\n", title, message); -#endif -} - -/* Pop up an out of memory message, returns to Windows */ -static bool OutOfMemory(void) -{ - ShowError("Fatal Error", "Out of memory - aborting"); - return FALSE; -} - -/* SDL_Quit() shouldn't be used with atexit() directly because - calling conventions may differ... */ -static void cleanup(void) -{ - SDL_Quit(); -} - -/* Remove the output files if there was no output written */ -static void cleanup_output(void) -{ -#if 1 -#ifndef NO_STDIO_REDIRECT - FILE *file; -#endif -#endif - - /* Flush the output in case anything is queued */ - fclose(stdout); - fclose(stderr); - -#if 1 -#ifndef NO_STDIO_REDIRECT - /* See if the files have any output in them */ - if ( stdoutPath[0] ) { - file = fopen(stdoutPath, TEXT("r")); - if ( file ) { - char buf[16384]; - size_t readbytes = fread(buf, 1, 16383, file); - fclose(file); - - if(readbytes != 0) - { - buf[readbytes] = 0; // cut after last byte (<=16383) - MessageBox(NULL, buf, "Wolf4SDL", MB_OK); - } - else - remove(stdoutPath); // remove empty file - } - } - if ( stderrPath[0] ) { - file = fopen(stderrPath, TEXT("rb")); - if ( file ) { - char buf[16384]; - size_t readbytes = fread(buf, 1, 16383, file); - fclose(file); - - if(readbytes != 0) - { - buf[readbytes] = 0; // cut after last byte (<=16383) - MessageBox(NULL, buf, "Wolf4SDL", MB_OK); - } - else - remove(stderrPath); // remove empty file - } - } -#endif -#endif -} - -//#if defined(_MSC_VER) && !defined(_WIN32_WCE) -///* The VC++ compiler needs main defined */ -//#define console_main main -//#endif - -/* This is where execution begins [console apps] */ -int console_main(int argc, char *argv[]) -{ - size_t n; - char *bufp, *appname; - int status; - - /* Get the class name from argv[0] */ - appname = argv[0]; - if ( (bufp=SDL_strrchr(argv[0], '\\')) != NULL ) { - appname = bufp+1; - } else - if ( (bufp=SDL_strrchr(argv[0], '/')) != NULL ) { - appname = bufp+1; - } - - if ( (bufp=SDL_strrchr(appname, '.')) == NULL ) - n = SDL_strlen(appname); - else - n = (bufp-appname); - - bufp = SDL_stack_alloc(char, n+1); - if ( bufp == NULL ) { - return OutOfMemory(); - } - SDL_strlcpy(bufp, appname, n+1); - appname = bufp; - - /* Load SDL dynamic link library */ - if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { - ShowError("WinMain() error", SDL_GetError()); - return(FALSE); - } - atexit(cleanup_output); - atexit(cleanup); - - /* Sam: - We still need to pass in the application handle so that - DirectInput will initialize properly when SDL_RegisterApp() - is called later in the video initialization. - */ - SDL_SetModuleHandle(GetModuleHandle(NULL)); - - /* Run the application main() code */ - status = SDL_main(argc, argv); - - /* Exit cleanly, calling atexit() functions */ - exit(status); - - /* Hush little compiler, don't you cry... */ - return 0; -} - -/* 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; - char **argv; - int argc; - char *cmdline; -#ifdef _WIN32_WCE - wchar_t *bufp; - int nLen; -#else - char *bufp; - size_t nLen; -#endif -#ifndef NO_STDIO_REDIRECT - DWORD pathlen; -#ifdef _WIN32_WCE - wchar_t path[MAX_PATH]; -#else - char path[MAX_PATH]; -#endif - FILE *newfp; -#endif - - /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't - keep them open. This is a hack.. hopefully it will be fixed - someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. - */ - handle = LoadLibrary(TEXT("DDRAW.DLL")); - if ( handle != NULL ) { - FreeLibrary(handle); - } - -#ifndef NO_STDIO_REDIRECT - pathlen = GetModuleFileName(NULL, path, SDL_arraysize(path)); - while ( pathlen > 0 && path[pathlen] != '\\' ) { - --pathlen; - } - path[pathlen] = '\0'; - -#ifdef _WIN32_WCE - wcsncpy( stdoutPath, path, SDL_arraysize(stdoutPath) ); - wcsncat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) ); -#else - SDL_strlcpy( stdoutPath, path, SDL_arraysize(stdoutPath) ); - SDL_strlcat( stdoutPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) ); -#endif - - /* Redirect standard input and standard output */ - newfp = freopen(stdoutPath, TEXT("w"), stdout); - -#ifndef _WIN32_WCE - if ( newfp == NULL ) { /* This happens on NT */ -#if !defined(stdout) - stdout = fopen(stdoutPath, TEXT("w")); -#else - newfp = fopen(stdoutPath, TEXT("w")); - if ( newfp ) { - *stdout = *newfp; - } -#endif - } -#endif /* _WIN32_WCE */ - -#ifdef _WIN32_WCE - wcsncpy( stderrPath, path, SDL_arraysize(stdoutPath) ); - wcsncat( stderrPath, DIR_SEPERATOR STDOUT_FILE, SDL_arraysize(stdoutPath) ); -#else - SDL_strlcpy( stderrPath, path, SDL_arraysize(stderrPath) ); - SDL_strlcat( stderrPath, DIR_SEPERATOR STDERR_FILE, SDL_arraysize(stderrPath) ); -#endif - - newfp = freopen(stderrPath, TEXT("w"), stderr); -#ifndef _WIN32_WCE - if ( newfp == NULL ) { /* This happens on NT */ -#if !defined(stderr) - stderr = fopen(stderrPath, TEXT("w")); -#else - newfp = fopen(stderrPath, TEXT("w")); - if ( newfp ) { - *stderr = *newfp; - } -#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 = SDL_stack_alloc(wchar_t, 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 = SDL_stack_alloc(char, nLen); - if ( cmdline == NULL ) { - return OutOfMemory(); - } - WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); -#else - /* Grab the command line */ - bufp = GetCommandLine(); - nLen = SDL_strlen(bufp)+1; - cmdline = SDL_stack_alloc(char, nLen); - if ( cmdline == NULL ) { - return OutOfMemory(); - } - SDL_strlcpy(cmdline, bufp, nLen); -#endif - - /* Parse it into argv and argc */ - argc = ParseCommandLine(cmdline, NULL); - argv = SDL_stack_alloc(char*, argc+1); - if ( argv == NULL ) { - return OutOfMemory(); - } - ParseCommandLine(cmdline, argv); - - /* Run the main program (after a little SDL initialization) */ - console_main(argc, argv); - - /* Hush little compiler, don't you cry... */ - return 0; -} - -#endif // _WIN32 diff --git a/apps/plugins/sdl/progs/wolf3d/wl_def.h b/apps/plugins/sdl/progs/wolf3d/wl_def.h index 1b8670ffb6..13ec77cf70 100644 --- a/apps/plugins/sdl/progs/wolf3d/wl_def.h +++ b/apps/plugins/sdl/progs/wolf3d/wl_def.h @@ -1392,23 +1392,17 @@ static fixed FixedMul(fixed a, fixed b) #define CHECKMALLOCRESULT(x) if(!(x)) Quit("Out of memory at %s:%i", __FILE__, __LINE__) -#ifdef _WIN32 - #define strcasecmp stricmp - #define strncasecmp strnicmp - #define snprintf _snprintf -#else - static char* itoa(int value, char* string, int radix) - { - sprintf(string, "%d", value); - return string; - } +static char* itoa(int value, char* string, int radix) +{ + sprintf(string, "%d", value); + return string; +} - static char* ltoa(long value, char* string, int radix) - { - sprintf(string, "%ld", value); - return string; - } -#endif +static char* ltoa(long value, char* string, int radix) +{ + sprintf(string, "%ld", value); + return string; +} #define lengthof(x) (sizeof(x) / sizeof(*(x))) #define endof(x) ((x) + lengthof(x)) diff --git a/apps/plugins/sdl/progs/wolf3d/wl_main.c b/apps/plugins/sdl/progs/wolf3d/wl_main.c index 634196498a..8808cd0883 100644 --- a/apps/plugins/sdl/progs/wolf3d/wl_main.c +++ b/apps/plugins/sdl/progs/wolf3d/wl_main.c @@ -1191,9 +1191,6 @@ static void InitGame() #endif // initialize SDL -#if defined _WIN32 - putenv("SDL_VIDEODRIVER=directx"); -#endif if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { printf("Unable to init SDL: %s\n", SDL_GetError()); @@ -1217,23 +1214,7 @@ static void InitGame() #endif SignonScreen (); - -#if defined _WIN32 - if(!fullscreen) - { - struct SDL_SysWMinfo wmInfo; - SDL_VERSION(&wmInfo.version); - - if(SDL_GetWMInfo(&wmInfo) != -1) - { - HWND hwndSDL = wmInfo.window; - DWORD style = GetWindowLong(hwndSDL, GWL_STYLE) & ~WS_SYSMENU; - SetWindowLong(hwndSDL, GWL_STYLE, style); - SetWindowPos(hwndSDL, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); - } - } -#endif - + VH_Startup (); IN_Startup (); PM_Startup (); @@ -1911,11 +1892,7 @@ void CheckParameters(int argc, char *argv[]) " --ignorenumchunks Ignores the number of chunks in VGAHEAD.*\n" " (may be useful for some broken mods)\n" " --configdir Directory where config file and save games are stored\n" -#if defined(_arch_dreamcast) || defined(_WIN32) - " (default: current directory)\n" -#else " (default: $HOME/.wolf4sdl)\n" -#endif #if defined(SPEAR) && !defined(SPEARDEMO) " --mission Mission number to play (0-3)\n" " (default: 0 -> .sod, 1-3 -> .sd*)\n" diff --git a/apps/plugins/sdl/progs/wolf3d/wl_menu.c b/apps/plugins/sdl/progs/wolf3d/wl_menu.c index d72f0733c2..cdbc70aad1 100644 --- a/apps/plugins/sdl/progs/wolf3d/wl_menu.c +++ b/apps/plugins/sdl/progs/wolf3d/wl_menu.c @@ -3992,7 +3992,6 @@ CheckForEpisodes (void) int statbuf; // On Linux like systems, the configdir defaults to $HOME/.wolf4sdl -#if !defined(_WIN32) && !defined(_arch_dreamcast) if(configdir[0] == 0) { // Set config location to home directory for multi-user support @@ -4008,18 +4007,13 @@ CheckForEpisodes (void) } snprintf(configdir, sizeof(configdir), "%s" WOLFDIR, homedir); } -#endif if(configdir[0] != 0) { // Ensure config directory exists and create if necessary if(stat(configdir, &statbuf) != 0) { -#ifdef _WIN32 - if(_mkdir(configdir) != 0) -#else if(mkdir(configdir) != 0) -#endif { Quit("The configuration directory \"%s\" could not be created.", configdir); } diff --git a/apps/plugins/sdl/src/stdlib/SDL_malloc.c b/apps/plugins/sdl/src/stdlib/SDL_malloc.c index f025e4349a..e049a76c6b 100644 --- a/apps/plugins/sdl/src/stdlib/SDL_malloc.c +++ b/apps/plugins/sdl/src/stdlib/SDL_malloc.c @@ -241,10 +241,6 @@ Be careful in setting #define values for numerical constants of type size_t. On some systems, literal values are not automatically extended to size_t precision unless they are explicitly casted. -WIN32 default: defined if _WIN32 defined - Defining WIN32 sets up defaults for MS environment and compilers. - Otherwise defaults are for unix. - MALLOC_ALIGNMENT default: (size_t)8 Controls the minimum alignment for malloc'ed chunks. It must be a power of two and at least 8, even on machines for which smaller @@ -474,28 +470,6 @@ DEFAULT_MMAP_THRESHOLD default: 256K */ -#ifndef WIN32 -#ifdef _WIN32 -#define WIN32 1 -#endif /* _WIN32 */ -#endif /* WIN32 */ -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#define HAVE_MMAP 1 -#define HAVE_MORECORE 0 -#define LACKS_UNISTD_H -#define LACKS_SYS_PARAM_H -#define LACKS_SYS_MMAN_H -#define LACKS_STRING_H -#define LACKS_STRINGS_H -#define LACKS_SYS_TYPES_H -#define LACKS_ERRNO_H -#define LACKS_FCNTL_H -#define MALLOC_FAILURE_ACTION -#define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */ -#endif /* WIN32 */ - #if defined(DARWIN) || defined(_DARWIN) /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ #ifndef HAVE_MORECORE