1
0
Fork 0
forked from len0rd/rockbox

sdl: Remove platform-specific code

Also nuke the Makefiles of Duke Nukem 3D (pun intended).

Change-Id: If2707cf079bfb9299347f9c5f980780134b6ecda
This commit is contained in:
Vencislav Atanasov 2019-07-28 23:31:50 +03:00
parent e19857e712
commit 183e45e8d0
No known key found for this signature in database
GPG key ID: 4B991E20465BE1F1
49 changed files with 53 additions and 2191 deletions

View file

@ -7,11 +7,8 @@
#ifndef _INCLUDE_BUILD_H_
#define _INCLUDE_BUILD_H_
#ifdef _WIN32
#include "windows/inttypes.h"
#else
#include <inttypes.h>
#endif
#include <inttypes.h>
#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.

View file

@ -69,10 +69,6 @@ void TIMER_GetPlatformTicks(int64_t* t);
#if ((defined PLATFORM_WIN32))
#include <windows.h>
#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 ... */

View file

@ -8,11 +8,7 @@
#ifndef _INCLUDE_A_H_
#define _INCLUDE_A_H_
#ifdef _WIN32
#include "windows/inttypes.h"
#else
#include <inttypes.h>
#endif
#include <inttypes.h>
//C++ linker friendly

View file

@ -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,

View file

@ -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

View file

@ -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 <stdlib.h>
#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 <inttypes.h>
#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 <assert.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#define USER_DUMMY_NETWORK 1
#endif

View file

@ -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,&regs,&regs);
}
void deinit_network_transport(gcomtype *gcom)
{
/* no-op, apparently. */
}
#elif UDP_NETWORKING
#if PLATFORM_WIN32
# include <winsock.h>
# 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 <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
@ -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)

View file

@ -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,&regs,&regs,&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)

View file

@ -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_ */

View file

@ -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 <stdlib.h>
#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 <inttypes.h>
#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 <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
#define USER_DUMMY_NETWORK 1
#endif

View file

@ -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 <stdio.h>
#if (!defined _MSC_VER)
#include <unistd.h>
#else
#include <fcntl.h>
#include <SYS\STAT.H>
#endif
#include <stdlib.h>
#include <io.h>
#include <direct.h>
#include <conio.h>
#include <dos.h>
#include <assert.h>
#include <string.h>
#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 ... */

View file

@ -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 <inttypes.h>
#endif
enum DPMI_Errors
{

View file

@ -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 <inttypes.h>
#endif
#include <inttypes.h>
typedef struct
{

View file

@ -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);
*/

View file

@ -24,11 +24,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#if PLATFORM_DOS
#include <conio.h>
#include <dos.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -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)

View file

@ -1,11 +1,7 @@
#ifndef _CVARDEFS_H_
#define _CVARDEFS_H_
#ifdef _WIN32
#include "../../Engine/src/windows/inttypes.h"
#else
#include <inttypes.h>
#endif
#include <inttypes.h>
void CVARDEFS_Init();
void CVARDEFS_Render();

View file

@ -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 <inttypes.h>
#endif
#include <inttypes.h>
typedef void (*function_t) (void* binding);

View file

@ -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 <inttypes.h>
#endif
#include <fcntl.h>
#include <time.h>
@ -50,26 +46,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
#endif
#endif
#if PLATFORM_DOS
#include <dos.h>
#include <bios.h>
#include <io.h>
#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

View file

@ -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

View file

@ -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 <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <assert.h>
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

View file

@ -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 <sys/stat.h>
#include <io.h>
#include <assert.h>
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

View file

@ -24,11 +24,7 @@
*/
//-------------------------------------------------------------------------
#ifdef _WIN32
#include <windows.h>
#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.

View file

@ -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);

View file

@ -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;
}

View file

@ -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

View file

@ -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];

View file

@ -24,10 +24,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#if PLATFORM_DOS
#include <conio.h>
#endif
#include <stdio.h>
#include <string.h>
#include "../../Game/src/types.h"

View file

@ -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 <inttypes.h>
#endif
#include <inttypes.h>
#ifdef __cplusplus
extern "C" {

View file

@ -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 <inttypes.h>
#endif
#include <inttypes.h>
#ifndef _util_lib_public
#define _util_lib_public