summaryrefslogtreecommitdiff
path: root/apps/plugins/sdl/progs/duke3d/Engine
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sdl/progs/duke3d/Engine')
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/build.h15
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/display.c37
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/draw.h6
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/engine.c6
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/filesystem.h2
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/macos_compat.h62
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/mmulti.c118
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/multi.c194
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/platform.h16
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/unix_compat.h67
-rw-r--r--apps/plugins/sdl/progs/duke3d/Engine/src/win32_compat.h106
11 files changed, 6 insertions, 623 deletions
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 @@
7 7
8#ifndef _INCLUDE_BUILD_H_ 8#ifndef _INCLUDE_BUILD_H_
9#define _INCLUDE_BUILD_H_ 9#define _INCLUDE_BUILD_H_
10#ifdef _WIN32 10
11 #include "windows/inttypes.h" 11#include <inttypes.h>
12#else
13 #include <inttypes.h>
14#endif
15 12
16#define MAXSECTORS 1024 13#define MAXSECTORS 1024
17#define MAXWALLS 8192 14#define MAXWALLS 8192
@@ -223,12 +220,8 @@ SPRITE VARIABLES:
223 220
224 Example: if the linked lists look like the following: 221 Example: if the linked lists look like the following:
225 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 222 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
226 ³ Sector lists: Status lists: ³ 223 ? Sector lists: Status lists: ? ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
227 ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ 224 ? Sector0: 4, 5, 8 Status0: 2, 0, 8 ? ? Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 ? ? Sector2: 3, 9 ? ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
228 ³ Sector0: 4, 5, 8 Status0: 2, 0, 8 ³
229 ³ Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 ³
230 ³ Sector2: 3, 9 ³
231 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
232 Notice that each number listed above is shown exactly once on both the 225 Notice that each number listed above is shown exactly once on both the
233 left and right side. This is because any sprite that exists must 226 left and right side. This is because any sprite that exists must
234 be in some sector, and must have some kind of status that you define. 227 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);
69 69
70 70
71 71
72#if ((defined PLATFORM_WIN32))
73#include <windows.h>
74#endif
75
76#include "draw.h" 72#include "draw.h"
77#include "cache.h" 73#include "cache.h"
78 74
@@ -763,12 +759,6 @@ void _platform_init(int argc, char **argv, const char *title, const char *ico
763 } 759 }
764 760
765 761
766
767#ifdef __APPLE__
768 SDL_putenv("SDL_VIDEODRIVER=Quartz");
769#endif
770
771
772 if (SDL_Init(SDL_INIT_VIDEO) == -1){ 762 if (SDL_Init(SDL_INIT_VIDEO) == -1){
773 Error(EXIT_FAILURE, "BUILDSDL: SDL_Init() failed!\nBUILDSDL: SDL_GetError() says \"%s\".\n", SDL_GetError()); 763 Error(EXIT_FAILURE, "BUILDSDL: SDL_Init() failed!\nBUILDSDL: SDL_GetError() says \"%s\".\n", SDL_GetError());
774 } 764 }
@@ -946,14 +936,11 @@ int32_t _setgamemode(uint8_t davidoption, int32_t daxdim, int32_t daydim)
946 SDL_Surface *image; 936 SDL_Surface *image;
947 Uint32 colorkey; 937 Uint32 colorkey;
948 938
949 // don't override higher-res app icon on OS X
950#ifndef PLATFORM_MACOSX
951 // Install icon 939 // Install icon
952 image = SDL_LoadBMP_RW(SDL_RWFromMem(iconBMP, iconBMP_size), 1); 940 image = SDL_LoadBMP_RW(SDL_RWFromMem(iconBMP, iconBMP_size), 1);
953 colorkey = 0; // index in this image to be transparent 941 colorkey = 0; // index in this image to be transparent
954 SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey); 942 SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
955 SDL_WM_SetIcon(image,NULL); 943 SDL_WM_SetIcon(image,NULL);
956#endif
957 944
958 if (daxdim > MAXXDIM || daydim > MAXYDIM) 945 if (daxdim > MAXXDIM || daydim > MAXYDIM)
959 { 946 {
@@ -1915,29 +1902,6 @@ void uninitkeys(void)
1915 /* does nothing in SDL. Key input handling is set up elsewhere. */ 1902 /* does nothing in SDL. Key input handling is set up elsewhere. */
1916} 1903}
1917 1904
1918
1919//unsigned int32_t getticks(void)
1920//{
1921// return(SDL_GetTicks());
1922//} /* getticks */
1923
1924
1925//Timer on windows 98 used to be really poor but now it is very accurate
1926// We can just use what SDL uses, no need for QueryPerformanceFrequency or QueryPerformanceCounter
1927// (which I bet SDL is using anyway).
1928#if 0//PLATFORM_WIN32
1929int TIMER_GetPlatformTicksInOneSecond(int64_t* t)
1930{
1931 QueryPerformanceFrequency((LARGE_INTEGER*)t);
1932 return 1;
1933}
1934
1935void TIMER_GetPlatformTicks(int64_t* t)
1936{
1937 QueryPerformanceCounter((LARGE_INTEGER*)t);
1938}
1939#else
1940//FCS: Let's try to use SDL again: Maybe SDL library is accurate enough now.
1941int TIMER_GetPlatformTicksInOneSecond(int64_t* t) 1905int TIMER_GetPlatformTicksInOneSecond(int64_t* t)
1942{ 1906{
1943 *t = 1000; 1907 *t = 1000;
@@ -1948,6 +1912,5 @@ void TIMER_GetPlatformTicks(int64_t* t)
1948{ 1912{
1949 *t = SDL_GetTicks(); 1913 *t = SDL_GetTicks();
1950} 1914}
1951#endif
1952/* end of sdl_driver.c ... */ 1915/* end of sdl_driver.c ... */
1953 1916
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 @@
8#ifndef _INCLUDE_A_H_ 8#ifndef _INCLUDE_A_H_
9#define _INCLUDE_A_H_ 9#define _INCLUDE_A_H_
10 10
11#ifdef _WIN32 11#include <inttypes.h>
12 #include "windows/inttypes.h"
13#else
14 #include <inttypes.h>
15#endif
16 12
17 13
18//C++ linker friendly 14//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,
3335 walltype *w; 3335 walltype *w;
3336 sectortype *sect; 3336 sectortype *sect;
3337 3337
3338#if ((defined PLATFORM_DOS) || (defined PLATFORM_WIN32))
3339 permissions = S_IWRITE;
3340#elif (defined PLATFORM_UNIX)
3341 permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
3342#elif (defined PLATFORM_ROCKBOX)
3343 permissions = 0644; 3338 permissions = 0644;
3344#endif
3345 3339
3346 if ((fil = rb->open(filename, 3340 if ((fil = rb->open(filename,
3347 O_BINARY|O_TRUNC|O_CREAT|O_WRONLY, 3341 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);
42 42
43int32_t TCkopen4load(const char *filename, int32_t readfromGRP); 43int32_t TCkopen4load(const char *filename, int32_t readfromGRP);
44 44
45#if defined(__APPLE__) || defined(__linux__)
46int32_t filelength(int32_t fd); 45int32_t filelength(int32_t fd);
47#endif
48 46
49#endif 47#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 @@
1//
2// macos_compat.h
3// Duke3D
4//
5// Created by fabien sanglard on 12-12-12.
6// Copyright (c) 2012 fabien sanglard. All rights reserved.
7//
8
9#ifndef Duke3D_macos_compat_h
10#define Duke3D_macos_compat_h
11
12#define PLATFORM_SUPPORTS_SDL
13
14#include <stdlib.h>
15
16#define kmalloc(x) malloc(x)
17#define kkmalloc(x) malloc(x)
18#define kfree(x) free(x)
19#define kkfree(x) free(x)
20
21#ifdef FP_OFF
22#undef FP_OFF
23#endif
24
25// Horrible horrible macro: Watcom allowed memory pointer to be cast
26// to a 32bits integer. The code is unfortunately stuffed with this :( !
27#define FP_OFF(x) ((int32_t) (x))
28
29#ifndef max
30#define max(x, y) (((x) > (y)) ? (x) : (y))
31#endif
32
33#ifndef min
34#define min(x, y) (((x) < (y)) ? (x) : (y))
35#endif
36
37#include <inttypes.h>
38#define __int64 int64_t
39
40#define O_BINARY 0
41
42#define UDP_NETWORKING 1
43
44#define PLATFORM_MACOSX 1
45
46#define SOL_IP SOL_SOCKET
47#define IP_RECVERR SO_BROADCAST
48
49#define stricmp strcasecmp
50#define strcmpi strcasecmp
51
52#include <assert.h>
53#include <sys/stat.h>
54#include <sys/types.h>
55#include <sys/uio.h>
56#include <unistd.h>
57#include <fcntl.h>
58#include <string.h>
59
60#define USER_DUMMY_NETWORK 1
61
62#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)
557 557
558void unstable_callcommit(void){} 558void unstable_callcommit(void){}
559 559
560#elif (defined PLATFORM_DOS)
561gcomtype *init_network_transport(char **ARGV, int argpos)
562{
563 /*
564 * How to talk to COMMIT is passed as a pointer to a block of memory
565 * that COMMIT.EXE configures...
566 */
567 return((gcomtype *)atol(ARGV[argpos])); /* UGH! --ryan. */
568} /* init_network_transport */
569
570static union REGS regs;
571
572#pragma aux longcall =\
573 "call eax",\
574 parm [eax]
575
576void callcommit(void)
577{
578 if (gcom->intnum&0xff00)
579 longcall(gcom->longcalladdress);
580 else
581 int386(gcom->intnum,&regs,&regs);
582}
583
584void deinit_network_transport(gcomtype *gcom)
585{
586 /* no-op, apparently. */
587}
588
589
590#elif UDP_NETWORKING 560#elif UDP_NETWORKING
591 561
592#if PLATFORM_WIN32
593# include <winsock.h>
594# define EAGAIN WSAEWOULDBLOCK
595# define EWOULDBLOCK WSAEWOULDBLOCK
596# define ECONNREFUSED WSAECONNRESET
597# define socklen_t size_t
598# define netstrerror() win32netstrerror()
599# define neterrno() WSAGetLastError()
600# define sockettype SOCKET
601# define socketclose(x) closesocket(x)
602#else
603# include <sys/types.h> 562# include <sys/types.h>
604# include <sys/socket.h> 563# include <sys/socket.h>
605# include <netinet/in.h> 564# include <netinet/in.h>
@@ -618,7 +577,6 @@ void deinit_network_transport(gcomtype *gcom)
618# ifndef MSG_ERRQUEUE /* legacy glibc header workaround... */ 577# ifndef MSG_ERRQUEUE /* legacy glibc header workaround... */
619# define MSG_ERRQUEUE 0x2000 578# define MSG_ERRQUEUE 0x2000
620# endif 579# endif
621#endif
622 580
623#define SOCKET_SHUTDOWN_BOTH 2 581#define SOCKET_SHUTDOWN_BOTH 2
624 582
@@ -650,47 +608,6 @@ static void siginthandler(int sigint)
650 ctrlc_pressed = 1; 608 ctrlc_pressed = 1;
651} 609}
652 610
653#if PLATFORM_WIN32
654/*
655 * Figure out what the last failing Win32 API call was, and
656 * generate a human-readable string for the error message.
657 *
658 * The return value is a static buffer that is overwritten with
659 * each call to this function.
660 *
661 * Code lifted from PhysicsFS: http://icculus.org/physfs/
662 */
663static const char *win32netstrerror(void)
664{
665 static TCHAR msgbuf[255];
666 TCHAR *ptr = msgbuf;
667
668 FormatMessage(
669 FORMAT_MESSAGE_FROM_SYSTEM |
670 FORMAT_MESSAGE_IGNORE_INSERTS,
671 NULL,
672 WSAGetLastError(), /*GetLastError(),*/
673 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
674 msgbuf,
675 sizeof (msgbuf) / sizeof (TCHAR),
676 NULL
677 );
678
679 /* chop off newlines. */
680 for (ptr = msgbuf; *ptr; ptr++)
681 {
682 if ((*ptr == '\n') || (*ptr == '\r'))
683 {
684 *ptr = ' ';
685 break;
686 } /* if */
687 } /* for */
688
689 return((const char *) msgbuf);
690} /* win32strerror */
691#endif
692
693
694typedef enum 611typedef enum
695{ 612{
696 udpmode_peer, 613 udpmode_peer,
@@ -758,7 +675,6 @@ static int get_udp_packet(int *ip, short *_port, void *pkt, size_t pktsize)
758 if (rc == -1) 675 if (rc == -1)
759 err = neterrno(); 676 err = neterrno();
760 677
761#if !PLATFORM_WIN32
762 /* !!! FIXME: Linux specific? */ 678 /* !!! FIXME: Linux specific? */
763 if (rc == -1) /* fill in the addr structure on error... */ 679 if (rc == -1) /* fill in the addr structure on error... */
764 { 680 {
@@ -766,7 +682,6 @@ static int get_udp_packet(int *ip, short *_port, void *pkt, size_t pktsize)
766 recvfrom(udpsocket, NULL, 0, MSG_ERRQUEUE, 682 recvfrom(udpsocket, NULL, 0, MSG_ERRQUEUE,
767 (struct sockaddr *) &addr, &l); 683 (struct sockaddr *) &addr, &l);
768 } 684 }
769#endif
770 685
771 *ip = ntohl(addr.sin_addr.s_addr); 686 *ip = ntohl(addr.sin_addr.s_addr);
772 port = ntohs(addr.sin_port); 687 port = ntohs(addr.sin_port);
@@ -933,10 +848,6 @@ static int set_socket_blockmode(int onOrOff)
933 848
934 /* set socket to be (non-)blocking. */ 849 /* set socket to be (non-)blocking. */
935 850
936#if PLATFORM_WIN32
937 flags = (onOrOff) ? 0 : 1;
938 rc = (ioctlsocket(udpsocket, FIONBIO, &flags) == 0);
939#else
940 flags = fcntl(udpsocket, F_GETFL, 0); 851 flags = fcntl(udpsocket, F_GETFL, 0);
941 if (flags != -1) 852 if (flags != -1)
942 { 853 {
@@ -946,7 +857,6 @@ static int set_socket_blockmode(int onOrOff)
946 flags |= O_NONBLOCK; 857 flags |= O_NONBLOCK;
947 rc = (fcntl(udpsocket, F_SETFL, flags) == 0); 858 rc = (fcntl(udpsocket, F_SETFL, flags) == 0);
948 } 859 }
949#endif
950 860
951 if (!rc) 861 if (!rc)
952 { 862 {
@@ -992,13 +902,11 @@ static int open_udp_socket(int ip, int port)
992 if (!set_socket_blockmode(0)) 902 if (!set_socket_blockmode(0))
993 return(0); 903 return(0);
994 904
995 #if !PLATFORM_WIN32
996 { 905 {
997 /* !!! FIXME: Might be Linux (not Unix, not BSD, not WinSock) specific. */ 906 /* !!! FIXME: Might be Linux (not Unix, not BSD, not WinSock) specific. */
998 int flags = 1; 907 int flags = 1;
999 setsockopt(udpsocket, SOL_IP, IP_RECVERR, &flags, sizeof (flags)); 908 setsockopt(udpsocket, SOL_IP, IP_RECVERR, &flags, sizeof (flags));
1000 } 909 }
1001 #endif
1002 910
1003 memset(&addr, '\0', sizeof (addr)); 911 memset(&addr, '\0', sizeof (addr));
1004 addr.sin_family = AF_INET; 912 addr.sin_family = AF_INET;
@@ -1376,37 +1284,11 @@ static int parse_interface(char *str, int *ip, short *udpport)
1376 1284
1377static int initialize_sockets(void) 1285static int initialize_sockets(void)
1378{ 1286{
1379#if PLATFORM_WIN32
1380 int rc;
1381 WSADATA data;
1382 printf("initializing WinSock...\n");
1383 rc = WSAStartup(0x0101, &data);
1384 if (rc != 0)
1385 {
1386 printf("WinSock failed to initialize! [err==%d].\n", rc);
1387 return(0);
1388 }
1389 else
1390 {
1391 printf("WinSock initialized.\n");
1392 printf(" - Caller uses version %d.%d, highest supported is %d.%d.\n",
1393 data.wVersion >> 8, data.wVersion & 0xFF,
1394 data.wHighVersion >> 8, data.wHighVersion & 0xFF);
1395 printf(" - Implementation description: [%s].\n", data.szDescription);
1396 printf(" - System status: [%s].\n", data.szSystemStatus);
1397 printf(" - Max sockets: %d.\n", data.iMaxSockets);
1398 printf(" - Max UDP datagram size: %d.\n", data.iMaxUdpDg);
1399 }
1400#endif
1401
1402 return(1); 1287 return(1);
1403} 1288}
1404 1289
1405static void deinitialize_sockets(void) 1290static void deinitialize_sockets(void)
1406{ 1291{
1407#if PLATFORM_WIN32
1408 WSACleanup();
1409#endif
1410} 1292}
1411 1293
1412static int parse_udp_config(const char *cfgfile, gcomtype *gcom) 1294static 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];
46 46
47 //COM ONLY variables 47 //COM ONLY variables
48long comnum, comvect, comspeed, comtemp, comi, comescape, comreset; 48long comnum, comvect, comspeed, comtemp, comi, comescape, comreset;
49#ifdef PLATFORM_DOS // !!! this is a real mess. --ryan.
50static void interrupt far comhandler(void);
51static unsigned short orig_pm_sel, orig_rm_seg, orig_rm_off;
52static unsigned long orig_pm_off;
53#endif
54volatile unsigned char *inbuf, *outbuf, *comerror, *incnt, *comtype; 49volatile unsigned char *inbuf, *outbuf, *comerror, *incnt, *comtype;
55volatile unsigned char *comresend; 50volatile unsigned char *comresend;
56volatile short *inbufplc, *inbufend, *outbufplc, *outbufend, *comport; 51volatile short *inbufplc, *inbufend, *outbufplc, *outbufend, *comport;
57#ifdef PLATFORM_DOS // !!! this is a real mess. --ryan.
58static char rmbuffer[COMCODEBYTES] = //See realcom.asm
59{
60 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
61 0x00,0x00,0x00,0x00,0x50,0x53,0x66,0x51,0x52,0x2e,
62 0x8b,0x16,0x08,0x00,0x83,0xc2,0x02,0xec,0x24,0x07,
63 0x8a,0xe0,0x80,0xfc,0x02,0x74,0x08,0x80,0xfc,0x04,
64 0x74,0x62,0xe9,0x89,0x00,0x2e,0x8b,0x16,0x08,0x00,
65 0x2e,0x8a,0x0e,0x0a,0x00,0x80,0xe9,0x01,0x78,0x7a,
66 0x2e,0x80,0x3e,0x0c,0x00,0x01,0x7c,0x10,0x74,0x04,
67 0xb0,0x83,0xeb,0x02,0xb0,0x8f,0xee,0x2e,0xfe,0x0e,
68 0x0c,0x00,0xeb,0xe3,0x2e,0x80,0x3e,0x0b,0x00,0x01,
69 0x7c,0x12,0x74,0x04,0xb0,0x83,0xeb,0x04,0x2e,0xa0,
70 0x0d,0x00,0xee,0x2e,0xfe,0x0e,0x0b,0x00,0xeb,0xc9,
71 0x2e,0x8b,0x1e,0x04,0x00,0x2e,0x3b,0x1e,0x06,0x00,
72 0x74,0x3c,0x2e,0x8a,0x87,0x80,0x41,0xee,0x43,0x81,
73 0xe3,0xff,0x3f,0x2e,0x89,0x1e,0x04,0x00,0xeb,0xab,
74 0x2e,0x8b,0x16,0x08,0x00,0xec,0x2e,0x8b,0x1e,0x02,
75 0x00,0x2e,0x88,0x87,0x80,0x01,0x43,0x81,0xe3,0xff,
76 0x3f,0x2e,0x89,0x1e,0x02,0x00,0x2e,0x80,0x3e,0x0a,
77 0x00,0x10,0x75,0x08,0x83,0xc2,0x05,0xec,0xa8,0x01,
78 0x75,0xd6,0xf6,0xc4,0x01,0x0f,0x84,0x56,0xff,0xb0,
79 0x20,0xe6,0x20,0x5a,0x66,0x59,0x5b,0x58,0xcf,
80};
81#endif
82 52
83 //NET ONLY variables 53 //NET ONLY variables
84short socket = 0x4949; 54short socket = 0x4949;
@@ -106,80 +76,17 @@ static char rmnetbuffer[NETCODEBYTES] =
106}; 76};
107static long my7a = 0; 77static long my7a = 0;
108 78
109#ifdef PLATFORM_DOS
110#pragma aux koutp =\
111 "out dx, al",\
112 parm [edx][eax]\
113
114#pragma aux kinp =\
115 "in al, dx",\
116 parm [edx]
117#endif
118
119long convalloc32 (long size) 79long convalloc32 (long size)
120{ 80{
121#ifdef PLATFORM_DOS
122 union REGS r;
123
124 r.x.eax = 0x0100; //DPMI allocate DOS memory
125 r.x.ebx = ((size+15)>>4); //Number of paragraphs requested
126 int386(0x31,&r,&r);
127
128 if (r.x.cflag != 0) return ((long)0); //Failed
129 return ((long)((r.x.eax&0xffff)<<4)); //Returns full 32-bit offset
130#else
131 fprintf (stderr, "%s, line %d; convalloc32() called\n", __FILE__, 81 fprintf (stderr, "%s, line %d; convalloc32() called\n", __FILE__,
132 __LINE__); 82 __LINE__);
133 return 0; 83 return 0;
134#endif
135} 84}
136 85
137#ifdef PLATFORM_DOS
138#pragma aux fixregistersaftersimulate =\
139 "cld",\
140 "push ds",\
141 "pop es",\
142
143static struct rminfo
144{
145 long EDI, ESI, EBP, ESP, EBX, EDX, ECX, EAX;
146 short flags, ES, DS, FS, GS, IP, CS, SP, SS;
147} RMI;
148#endif
149
150long simulateint(char intnum, long daeax, long daebx, long daecx, long daedx, long daesi, long daedi) 86long simulateint(char intnum, long daeax, long daebx, long daecx, long daedx, long daesi, long daedi)
151{ 87{
152#ifdef PLATFORM_DOS
153 union REGS regs;
154 struct SREGS sregs;
155
156 memset(&RMI,0,sizeof(RMI)); // Set up real-mode call structure
157 memset(&sregs,0,sizeof(sregs));
158
159 RMI.EAX = daeax;
160 RMI.EBX = daebx;
161 RMI.ECX = daecx;
162 RMI.EDX = daedx;
163 RMI.ESI = daesi-rmoffset32;
164 RMI.EDI = daedi-rmoffset32;
165 RMI.DS = rmsegment16;
166 RMI.ES = rmsegment16;
167
168 regs.w.ax = 0x0300; // Use DMPI call 300h to issue the DOS interrupt
169 regs.h.bl = intnum;
170 regs.h.bh = 0;
171 regs.w.cx = 0;
172 sregs.es = FP_SEG(&RMI);
173 regs.x.edi = FP_OFF(&RMI);
174 int386x(0x31,&regs,&regs,&sregs);
175
176 fixregistersaftersimulate();
177
178 return(RMI.EAX);
179#else
180 fprintf(stderr, "%s line %d; simulateint() called\n",__FILE__,__LINE__); 88 fprintf(stderr, "%s line %d; simulateint() called\n",__FILE__,__LINE__);
181 return 0; 89 return 0;
182#endif
183} 90}
184 91
185void initmultiplayers(char damultioption, char dacomrateoption, char dapriority) 92void initmultiplayers(char damultioption, char dacomrateoption, char dapriority)
@@ -237,22 +144,6 @@ int neton(void)
237 long i, j; 144 long i, j;
238 145
239 if ((simulateint(0x2f,(long)0x7a00,0L,0L,0L,0L,0L)&255) != 255) return(-1); 146 if ((simulateint(0x2f,(long)0x7a00,0L,0L,0L,0L,0L)&255) != 255) return(-1);
240 if (*(long *)(0x7a<<2) == 0)
241 {
242#ifdef PLATFORM_DOS
243 printf("Faking int 0x7a to call IPX entry at: %4x:%4x\n",RMI.ES,RMI.EDI&65535);
244 my7a = convalloc32(16L);
245 *(short *)((0x7a<<2)+0) = (my7a&15);
246 *(short *)((0x7a<<2)+2) = (my7a>>4);
247
248 *(char *)(my7a+0) = 0x2e; //call far ptr [L1]
249 *(char *)(my7a+1) = 0x9a;
250 *(long *)(my7a+2) = 7L;
251 *(char *)(my7a+6) = 0xcf; //iret
252 *(short *)(my7a+7) = (RMI.EDI&65535); //L1: ipxoff
253 *(short *)(my7a+9) = RMI.ES; // ipxseg
254#endif
255 }
256 147
257 //Special stuff for WATCOM C 148 //Special stuff for WATCOM C
258 if ((rmoffset32 = convalloc32(1380L+NETCODEBYTES+COMBUFSIZ)) == 0) 149 if ((rmoffset32 = convalloc32(1380L+NETCODEBYTES+COMBUFSIZ)) == 0)
@@ -349,9 +240,6 @@ int comon()
349 // Baud-Setting,?,?,Parity O/E,Parity Off/On, Stop-1/2,Bits-5/6/7/8 240 // Baud-Setting,?,?,Parity O/E,Parity Off/On, Stop-1/2,Bits-5/6/7/8
350 // 0x0b is odd parity,1 stop bit, 8 bits 241 // 0x0b is odd parity,1 stop bit, 8 bits
351 242
352#ifdef PLATFORM_DOS
353 _disable();
354#endif
355 koutp((*comport)+3,0x80); //enable latch registers 243 koutp((*comport)+3,0x80); //enable latch registers
356 divisor = 115200 / comspeed; 244 divisor = 115200 / comspeed;
357 koutp((*comport)+0,divisor&255); //# = 115200 / bps 245 koutp((*comport)+0,divisor&255); //# = 115200 / bps
@@ -384,9 +272,6 @@ int comon()
384 272
385 comescape = 0; comreset = 0; 273 comescape = 0; comreset = 0;
386 *comerror = 0; *comresend = 0; 274 *comerror = 0; *comresend = 0;
387#ifdef PLATFORM_DOS
388 _enable();
389#endif
390 275
391 syncbufleng = 0; 276 syncbufleng = 0;
392 277
@@ -410,18 +295,12 @@ void comoff()
410 i--; 295 i--;
411 } 296 }
412 297
413#ifdef PLATFORM_DOS
414 _disable();
415#endif
416 koutp(0x21,kinp(0x21)|(1<<(comvect&7))); //Mask vector 298 koutp(0x21,kinp(0x21)|(1<<(comvect&7))); //Mask vector
417 if (hangup != 0) 299 if (hangup != 0)
418 { 300 {
419 koutp((*comport)+1,0); 301 koutp((*comport)+1,0);
420 koutp((*comport)+4,0); 302 koutp((*comport)+4,0);
421 } 303 }
422#ifdef PLATFORM_DOS
423 _enable();
424#endif
425 uninstallbicomhandlers(); 304 uninstallbicomhandlers();
426} 305}
427 306
@@ -921,87 +800,14 @@ long getcrc(char *buffer, short bufleng)
921 800
922void installbicomhandlers(void) 801void installbicomhandlers(void)
923{ 802{
924#ifdef PLATFORM_DOS
925 union REGS r;
926 struct SREGS sr;
927 long lowp;
928 void far *fh;
929
930 //Get old protected mode handler
931 r.x.eax = 0x3500+comvect; /* DOS get vector (INT 0Ch) */
932 sr.ds = sr.es = 0;
933 int386x(0x21,&r,&r,&sr);
934 orig_pm_sel = (unsigned short)sr.es;
935 orig_pm_off = r.x.ebx;
936
937 //Get old real mode handler
938 r.x.eax = 0x0200; /* DPMI get real mode vector */
939 r.h.bl = comvect;
940 int386(0x31,&r,&r);
941 orig_rm_seg = (unsigned short)r.x.ecx;
942 orig_rm_off = (unsigned short)r.x.edx;
943
944 //Allocate memory in low memory to store real mode handler
945 if ((lowp = convalloc32(COMCODEBYTES+(COMBUFSIZ<<1))) == 0)
946 { printf("Can't allocate conventional memory.\n"); exit; }
947
948 inbufplc = (short *)(lowp+0);
949 inbufend = (short *)(lowp+2);
950 outbufplc = (short *)(lowp+4);
951 outbufend = (short *)(lowp+6);
952 comport = (short *)(lowp+8);
953 comtype = (char *)(lowp+10);
954 comerror = (char *)(lowp+11);
955 comresend = (char *)(lowp+12);
956 incnt = (char *)(lowp+13);
957 inbuf = (char *)(lowp+COMCODEBYTES);
958 outbuf = (char *)(lowp+COMCODEBYTES+COMBUFSIZ);
959
960 memcpy((void *)lowp,(void *)rmbuffer,COMCODEBYTES);
961
962 //Set new protected mode handler
963 r.x.eax = 0x2500+comvect; /* DOS set vector (INT 0Ch) */
964 fh = (void far *)comhandler;
965 r.x.edx = FP_OFF(fh);
966 sr.ds = FP_SEG(fh); //DS:EDX == &handler
967 sr.es = 0;
968 int386x(0x21,&r,&r,&sr);
969
970 //Set new real mode handler (must be after setting protected mode)
971 r.x.eax = 0x0201;
972 r.h.bl = comvect; //CX:DX == real mode &handler
973 r.x.ecx = ((lowp>>4)&0xffff); //D32realseg
974 r.x.edx = COMCODEOFFS; //D32realoff
975 int386(0x31,&r,&r);
976#else
977 fprintf (stderr,"%s, line %d; installbicomhandlers() called\n", 803 fprintf (stderr,"%s, line %d; installbicomhandlers() called\n",
978 __FILE__, __LINE__); 804 __FILE__, __LINE__);
979#endif
980} 805}
981 806
982void uninstallbicomhandlers(void) 807void uninstallbicomhandlers(void)
983{ 808{
984#ifdef PLATFORM_DOS
985 union REGS r;
986 struct SREGS sr;
987
988 //restore old protected mode handler
989 r.x.eax = 0x2500+comvect; /* DOS set vector (INT 0Ch) */
990 r.x.edx = orig_pm_off;
991 sr.ds = orig_pm_sel; /* DS:EDX == &handler */
992 sr.es = 0;
993 int386x(0x21,&r,&r,&sr);
994
995 //restore old real mode handler
996 r.x.eax = 0x0201; /* DPMI set real mode vector */
997 r.h.bl = comvect;
998 r.x.ecx = (unsigned long)orig_rm_seg; //CX:DX == real mode &handler
999 r.x.edx = (unsigned long)orig_rm_off;
1000 int386(0x31,&r,&r);
1001#else
1002 fprintf (stderr, "%s line %d; uninstallbicomhandlers() called\n", 809 fprintf (stderr, "%s line %d; uninstallbicomhandlers() called\n",
1003 __FILE__, __LINE__); 810 __FILE__, __LINE__);
1004#endif
1005} 811}
1006 812
1007void processreservedmessage(short tempbufleng, char *datempbuf) 813void 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 @@
1#ifndef _INCLUDE_PLATFORM_DUKE_H_ 1#ifndef _INCLUDE_PLATFORM_DUKE_H_
2#define _INCLUDE_PLATFORM_DUKE_H_ 2#define _INCLUDE_PLATFORM_DUKE_H_
3 3
4#if (defined PLATFORM_WIN32) 4#if (defined ROCKBOX)
5 #include "win32_compat.h"
6#elif (defined PLATFORM_UNIX)
7 #include "unix_compat.h"
8#elif (defined PLATFORM_DOS)
9 #include "doscmpat.h"
10#elif (defined __APPLE__)
11 #include "macos_compat.h"
12#elif (defined ROCKBOX)
13 #include "rockbox_compat.h" 5 #include "rockbox_compat.h"
14#else 6#else
15#error Define your platform! 7#error Define your platform!
@@ -21,15 +13,9 @@
21 13
22uint16_t _swap16(uint16_t D); 14uint16_t _swap16(uint16_t D);
23unsigned int _swap32(unsigned int D); 15unsigned int _swap32(unsigned int D);
24#if defined(PLATFORM_MACOSX) && defined(__ppc__)
25#define PLATFORM_BIGENDIAN 1
26#define BUILDSWAP_INTEL16(x) _swap16(x)
27#define BUILDSWAP_INTEL32(x) _swap32(x)
28#else
29#define PLATFORM_LITTLEENDIAN 1 16#define PLATFORM_LITTLEENDIAN 1
30#define BUILDSWAP_INTEL16(x) (x) 17#define BUILDSWAP_INTEL16(x) (x)
31#define BUILDSWAP_INTEL32(x) (x) 18#define BUILDSWAP_INTEL32(x) (x)
32#endif
33 19
34#endif /* !defined _INCLUDE_PLATFORM_H_ */ 20#endif /* !defined _INCLUDE_PLATFORM_H_ */
35 21
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 @@
1//
2// unix_compat.h
3// Duke3D
4//
5// Based on macos_compat.h
6// Copyright Wed, Jul 31, 2013, Juan Manuel Borges Caño (GPLv3+)
7//
8
9#ifndef Duke3D_unix_compat_h
10#define Duke3D_unix_compat_h
11
12//#define BYTE_ORDER LITTLE_ENDIAN
13#define PLATFORM_SUPPORTS_SDL
14
15#include <stdlib.h>
16
17#define kmalloc(x) malloc(x)
18#define kkmalloc(x) malloc(x)
19#define kfree(x) free(x)
20#define kkfree(x) free(x)
21
22#ifdef FP_OFF
23#undef FP_OFF
24#endif
25
26// Horrible horrible macro: Watcom allowed memory pointer to be cast
27// to a 32bits integer. The code is unfortunately stuffed with this :( !
28#define FP_OFF(x) ((int32_t) (x))
29
30#ifndef max
31#define max(x, y) (((x) > (y)) ? (x) : (y))
32#endif
33
34#ifndef min
35#define min(x, y) (((x) < (y)) ? (x) : (y))
36#endif
37
38#include <inttypes.h>
39#define __int64 int64_t
40
41#define O_BINARY 0
42
43#define UDP_NETWORKING 1
44
45#define PLATFORM_UNIX 1
46
47/*
48#define SOL_IP SOL_SOCKET
49#define IP_RECVERR SO_BROADCAST
50*/
51
52#define stricmp strcasecmp
53#define strcmpi strcasecmp
54
55#define S_IREAD S_IRUSR
56#include <assert.h>
57#include <sys/types.h>
58#include <sys/stat.h>
59#include <sys/uio.h>
60#include <unistd.h>
61#include <fcntl.h>
62#include <dirent.h>
63#include <string.h>
64
65#define USER_DUMMY_NETWORK 1
66
67#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 @@
1/*
2 * win32 compatibility header. Takes care of some legacy code issues
3 * and incompatibilities at the source level.
4 *
5 * Written by Ryan C. Gordon (icculus@clutteredmind.org)
6 *
7 * Please do NOT harrass Ken Silverman about any code modifications
8 * (including this file) to BUILD.
9 */
10
11/*
12 * "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
13 * Ken Silverman's official web site: "http://www.advsys.net/ken"
14 * See the included license file "BUILDLIC.TXT" for license info.
15 * This file IS NOT A PART OF Ken Silverman's original release
16 */
17
18
19
20#ifndef _INCLUDE_WIN32_COMPAT_H_
21#define _INCLUDE_WIN32_COMPAT_H_
22
23#if (!defined PLATFORM_WIN32)
24#error PLATFORM_WIN32 is not defined.
25#endif
26
27#define PLATFORM_SUPPORTS_SDL
28
29#include <stdio.h>
30
31#if (!defined _MSC_VER)
32 #include <unistd.h>
33#else
34 #include <fcntl.h>
35 #include <SYS\STAT.H>
36#endif
37
38#include <stdlib.h>
39#include <io.h>
40#include <direct.h>
41#include <conio.h>
42#include <dos.h>
43#include <assert.h>
44#include <string.h>
45
46#define kmalloc(x) malloc(x)
47#define kkmalloc(x) malloc(x)
48#define kfree(x) free(x)
49#define kkfree(x) free(x)
50
51#ifdef FP_OFF
52#undef FP_OFF
53#endif
54
55#define FP_OFF(x) ((long) (x))
56
57/* !!! This might be temporary. */
58#define printext16 printext256
59#define printext16_noupdate printext256_noupdate
60
61#ifndef max
62#define max(x, y) (((x) > (y)) ? (x) : (y))
63#endif
64
65#ifndef min
66#define min(x, y) (((x) < (y)) ? (x) : (y))
67#endif
68
69#if (defined __WATCOMC__)
70#define inline
71#pragma intrinsic(min);
72#pragma intrinsic(max);
73#define __int64 long long
74#endif
75
76#if (defined _MSC_VER)
77#if ((!defined _INTEGRAL_MAX_BITS) || (_INTEGRAL_MAX_BITS < 64))
78#error __int64 type not supported
79#endif
80
81#define open _open
82#define O_BINARY _O_BINARY
83#define O_RDONLY _O_RDONLY
84#define O_WRONLY _O_WRONLY
85#define O_RDWR _O_RDWR
86#define O_TRUNC _O_TRUNC
87#define O_CREAT _O_CREAT
88#define S_IREAD _S_IREAD
89#define S_IWRITE _S_IWRITE
90#define S_IRDWR _S_IRDWR
91#endif /* defined _MSC_VER */
92
93#define snprintf _snprintf
94
95#define strncasecmp strnicmp
96
97//Damn you Microsoft, how hard would it REALLY be to support C99 ?!??!?!
98#define inline
99#include "windows/inttypes.h"
100
101#endif
102
103/* end of win32_compat.h ... */
104
105
106