summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ccbaf69)
raw | patch | inline | side by side (parent: ccbaf69)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 9 Feb 2019 17:52:52 +0000 (20:52 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 10 Feb 2019 10:05:11 +0000 (13:05 +0300) |
src/game/Doom2DF.lpr | patch | blob | history | |
src/game/g_main.pas | patch | blob | history | |
src/lib/enet/enet.pp | patch | blob | history | |
src/lib/socket/socket.pas | [new file with mode: 0644] | patch | blob |
src/lib/watt32/watt32.pp | patch | blob | history | |
src/wrappers/sdl2/sdl2allegro.inc | patch | blob | history |
diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr
index 53020f419c5a1886f69eb0167ca032fb43cde9e2..10ec8fcfcde776a12d9e699bd5ae8353081f78aa 100644 (file)
--- a/src/game/Doom2DF.lpr
+++ b/src/game/Doom2DF.lpr
ENet in '../wrappers/enet/enet.pas',
{$ELSE}
ENet in '../lib/enet/enet.pp',
- {$IFDEF GO32V2}
+ {$IFDEF USE_WATT32}
Watt32 in '../lib/watt32/watt32.pp',
{$ENDIF}
+ {$IFDEF USE_LIBSOCKET}
+ Socket in '../lib/socket/socket.pas',
+ {$ENDIF}
{$ENDIF}
{$IFDEF USE_SDL2ALLEGRO}
Allegro in '../lib/allegro4/allegro.pas',
diff --git a/src/game/g_main.pas b/src/game/g_main.pas
index 4e38444dcb9c78e5ce6a3e0c0e04ab14ba9923f5..627ebb0162401d14d3384fa5963f709ce8d0ee4d 100644 (file)
--- a/src/game/g_main.pas
+++ b/src/game/g_main.pas
uses
{$INCLUDE ../nogl/noGLuses.inc}
-{$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+{$IFDEF USE_WATT32}
Watt32,
{$ENDIF}
+{$IFDEF USE_LIBSOCKET}
+ Socket,
+{$ENDIF}
{$IFDEF ENABLE_HOLMES}
g_holmes, fui_wadread, fui_style, fui_gfx_gl,
{$ENDIF}
TMsgType.Notify
);
-{$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+{$IFDEF USE_WATT32}
sdlflags := sock_init;
{$IFDEF USE_SDL2ALLEGRO}
hires_timer(0);
init_userSuppliedTimerTick;
{$ENDIF}
- e_WriteLog('Wattcp Init: (' + IntToStr(sdlflags) + ') ' + sock_init_err, TMsgType.Notify);
+ e_WriteLog('Wattcp Init: (' + IntToStr(sdlflags) + ') ' + sock_init_err(sdlflags), TMsgType.Notify);
e_WriteLog('Wattcp Version: ' + wattcpVersion, TMsgType.Notify);
e_WriteLog('Wattcp Capabilities: ' + wattcpCapabilities, TMsgType.Notify);
e_WriteLog('Wattcp IP: ' +
TMsgType.Notify
);
{$ENDIF}
+{$IFDEF USE_LIBSOCKET}
+ sdlflags := __lsck_init;
+ e_WriteLog('libsocket Init: (' + IntToStr(sdlflags) + ') ' + lsck_strerror(sdlflags), TMsgType.Notify);
+ e_WriteLog('libsocket Version: ' + __lsck_get_version, TMsgType.Notify);
+{$ENDIF}
{$IFDEF HEADLESS}
conbufDumpToStdOut := true;
diff --git a/src/lib/enet/enet.pp b/src/lib/enet/enet.pp
index 4aa383d2e55e254715ddba63a570cbbdeea0182c..1a75e2f311652ba6bc71230e9ece1c5123a6c9e4 100644 (file)
--- a/src/lib/enet/enet.pp
+++ b/src/lib/enet/enet.pp
interface
uses
- ctypes,
-{$IF DEFINED(WINDOWS)}
- WinSock2;
-{$ELSEIF DEFINED(GO32V2)}
- Watt32;
+{$IF DEFINED(USE_WATT32)}
+ Watt32,
+{$ELSEIF DEFINED(USE_LIBSOCKET)}
+ Socket,
+{$ELSEIF DEFINED(WINDOWS)}
+ WinSock2,
{$ELSE}
- BaseUnix, Sockets;
+ BaseUnix, Sockets,
{$ENDIF}
+ ctypes;
////////////////////////////////////////////////////////////////////////////////
// types.h
diff --git a/src/lib/socket/socket.pas b/src/lib/socket/socket.pas
--- /dev/null
@@ -0,0 +1,135 @@
+// TCP/IP stack for winDOS
+// ftp://ftp.delorie.com/pub/djgpp/current/v2tk/ls080b.zip
+// ftp://ftp.delorie.com/pub/djgpp/current/v2tk/ls080d.zip
+// ftp://ftp.delorie.com/pub/djgpp/current/v2tk/ls080s.zip
+
+{$MODE OBJFPC}
+{$PACKRECORDS C}
+
+{$MODESWITCH OUT}
+{$LONGSTRINGS ON}
+{$MACRO ON}
+
+{$LINKLIB libsocket.a}
+{$LINKLIB libc.a}
+{$DEFINE LibraryLibSockDecl := cdecl}
+{$DEFINE LibraryLibSockImp := cdecl; external}
+{$DEFINE LibraryLibSockVar := cvar; external}
+
+unit socket;
+
+interface
+
+ uses ctypes;
+
+ (* Start-up & shutdown *)
+ function __lsck_init: cint; LibraryLibSockImp;
+ procedure __lsck_uninit; LibraryLibSockImp;
+
+ (* Configuration *)
+ function __lsck_config_getdir: PChar; LibraryLibSockImp;
+ function __lsck_config_setdir (newdir: PChar): PChar; LibraryLibSockImp;
+ function __lsck_config_getfile: PChar; LibraryLibSockImp;
+ function __lsck_config_setfile (newfile: PChar): PChar; LibraryLibSockImp;
+
+ (* DNS address(es) *)
+ function __lsck_getdnsaddr: PChar; LibraryLibSockImp;
+ function __lsck_getdnsaddrs: PPChar; LibraryLibSockImp;
+
+ (* Error fudging *)
+ //function lsck_strerror (errnum: cint): PChar; LibraryLibSockImp;
+ function lsck_strerror (errnum: cint): PChar; LibraryLibSockImp name 'strerror';
+
+ (* File descriptor tests *)
+ function __fd_is_socket (fd: cint): cint; LibraryLibSockImp;
+ function __fd_is_valid (fd: cint): cint; LibraryLibSockImp;
+
+ (* Debugging *)
+ const
+ LSCK_DEBUG_OFF = 0;
+ LSCK_DEBUG_NORMAL = 1;
+ LSCK_DEBUG_VERBOSE = 2;
+ LSCK_DEBUG_ON = LSCK_DEBUG_NORMAL;
+
+ procedure __lsck_debug_setlevel (level: cint); LibraryLibSockImp;
+ function __lsck_debug_getlevel: cint; LibraryLibSockImp;
+ procedure __lsck_debug_enable; LibraryLibSockImp;
+ procedure __lsck_debug_disable; LibraryLibSockImp;
+ function __lsck_debug_enabled: cint; LibraryLibSockImp;
+
+ (* lsck/copyrite.h *)
+ function __lsck_get_version: PChar; LibraryLibSockImp;
+ function __lsck_get_copyright: PChar; LibraryLibSockImp;
+
+ (* lsck/domname.h *)
+ function getdomainname (name: PChar; len: csize_t): cint; LibraryLibSockImp;
+ function setdomainname (const name: PChar; len: csize_t): cint; LibraryLibSockImp;
+
+ (* lsck/hostname.h *)
+ function gethostname (buf: PChar; size: cint): cint; LibraryLibSockImp;
+ function sethostname (buf: PChar; size: cint): cint; LibraryLibSockImp;
+
+ (* lsck/if.h *)
+ {...}
+
+
+
+ function htonl (_val: culong): culong; LibraryLibSockImp;
+ function ntohl (_val: culong): culong; LibraryLibSockImp;
+ function htons (_val: cushort): cushort; LibraryLibSockImp;
+ function ntohs (_val: cushort): cushort; LibraryLibSockImp;
+
+
+
+ (* MACRO *)
+ const
+ FD_MAXFDSET = 256; (* FD_SETSIZE *)
+
+ type
+ (* djgpp sys-include -> sys/wtypes.h -> fd_set *)
+ TFDSet = record
+ fd_bits: array [0..(FD_MAXFDSET + 7) DIV 8] of cuchar;
+ end;
+
+ function fpFD_SET (fdno: cint; var nset: TFDSet): cint;
+ function fpFD_CLR (fdno: cint; var nset: TFDSet): cint;
+ function fpFD_ZERO (out nset: TFDSet): cint;
+ function fpFD_ISSET (fdno: cint; const nset: TFDSet): cint;
+
+implementation
+
+ function fpFD_SET (fdno: cint; var nset: TFDSet): cint;
+ begin
+ if (fdno < 0) or (fdno > FD_MAXFDSET) then
+ exit(-1);
+ nset.fd_bits[fdno div 8] := nset.fd_bits[fdno div 8] OR (culong(1) shl (fdno and 7));
+ fpFD_SET := 0
+ end;
+
+ function fpFD_CLR (fdno: cint; var nset: TFDSet): cint;
+ begin
+ if (fdno < 0) or (fdno > FD_MAXFDSET) Then
+ exit(-1);
+ nset.fd_bits[fdno div 8] := nset.fd_bits[fdno div 8] AND Cardinal(NOT (culong(1) shl (fdno and 7)));
+ fpFD_CLR := 0
+ end;
+
+ function fpFD_ZERO (out nset: TFDSet): cint;
+ var i: longint;
+ begin
+ for i := 0 to (FD_MAXFDSET + 7) div 8 DO
+ nset.fd_bits[i] := 0;
+ fpFD_ZERO := 0
+ end;
+
+ function fpFD_ISSET (fdno: cint; const nset: TFDSet): cint;
+ begin
+ if (fdno < 0) or (fdno > FD_MAXFDSET) Then
+ exit(-1);
+ if ((nset.fd_bits[fdno div 8]) and (culong(1) shl (fdno and 7))) > 0 then
+ fpFD_ISSET := 1
+ else
+ fpFD_ISSET := 0
+ end;
+
+end.
index 60eb9268e4c4097c897294651e6a4c23b450e268..31011ca287ccb0d7a471984320df2b58cb0fdc85 100644 (file)
--- a/src/lib/watt32/watt32.pp
+++ b/src/lib/watt32/watt32.pp
+// TCP/IP stack for DOS
+// ftp://ftp.delorie.com/pub/djgpp/current/v2tk/wat3222br6.zip
+// ftp://ftp.delorie.com/pub/djgpp/current/v2tk/wat3222sr6.zip
+
{$MODE OBJFPC}
{$PACKRECORDS C}
uses ctypes;
const
+ (* socket size have another size on 64-bit systems *)
+ W32_UNDOC_TCP_SOCKET_SIZE = 4470;
+ W32_UNDOC_UDP_SOCKET_SIZE = 4470;
FD_MAXFDSET = 512; (* FD_SETSIZE *)
type
end;
tcp_Socket = record
- undoc: array [0..4469] of cuchar;
+ undoc: array [0..W32_UNDOC_TCP_SOCKET_SIZE - 1] of cuchar;
end;
udp_Socket = record
- undoc: array [0..1739] of cuchar;
+ undoc: array [0..W32_UNDOC_UDP_SOCKET_SIZE - 1] of cuchar;
end;
Psock_type = Pointer;
var
+ wattcpCopyrigh: PChar; LibraryLibWattVar;
my_ip_addr: culong; external name '__w32_my_ip_addr';
- function wattcpCopyright: PChar; LibraryLibWattImp;
function wattcpVersion: PChar; LibraryLibWattImp;
function wattcpCapabilities: PChar; LibraryLibWattImp;
+ function wattcpBuildCC: PChar; LibraryLibWattImp;
+ function wattcpBuildCCexe: PChar; LibraryLibWattImp;
+ function wattcpBuildCflags: PChar; LibraryLibWattImp;
+
+ function sock_init: cint; inline; (* MACRO *)
+ function watt_sock_init (tcp_Sock_size, udp_Sock_size, time_t_size: csize_t): cint; LibraryLibWattImp;
- function watt_sock_init (tcp, udp: csize_t): cint; LibraryLibWattImp;
- function sock_init_err: PChar; LibraryLibWattImp;
+ function sock_init_err (rc: cint): PChar; LibraryLibWattImp name '_w32_sock_init_err';
procedure sock_exit; LibraryLibWattImp;
procedure dbug_init; LibraryLibWattImp;
procedure init_misc; LibraryLibWattImp;
procedure sock_sig_exit (const msg: PChar; sigint: cint); LibraryLibWattImp;
function hires_timer (on: cint): cint; LibraryLibWattImp name '_w32_hires_timer';
- procedure init_userSuppliedTimerTick; LibraryLibWattImp;
- procedure userTimerTick (elapsed_time_msec: culong); LibraryLibWattImp;
- procedure init_timer_isr; LibraryLibWattImp name '_w32_init_timer_isr';
- procedure exit_timer_isr; LibraryLibWattImp name '_w32_exit_timer_isr';
- function tcp_tick (s: Psock_type): culong; LibraryLibWattImp;
+ procedure init_userSuppliedTimerTick; LibraryLibWattImp name '_w32_init_userSuppliedTimerTick';
+ procedure userTimerTick (elapsed_time_msec: culong); LibraryLibWattImp name '_w32_userTimerTick';
+ procedure init_timer_isr; LibraryLibWattImp;
+ procedure exit_timer_isr; LibraryLibWattImp;
+ function tcp_tick (s: Psock_type): culong; LibraryLibWattImp name '_w32_tcp_tick';
function htons (hostshort: cuint16): cuint16; LibraryLibWattImp;
function htonl (hostlong: cuint32): cuint32; LibraryLibWattImp;
function ntohl (netlong: cuint32): cuint32; LibraryLibWattImp;
(* MACRO *)
- function sock_init: cint;
function fpFD_SET (fdno: cint; var nset: TFDSet): cint;
function fpFD_CLR (fdno:cint; var nset: TFDSet): cint;
function fpFD_ZERO (out nset: TFDSet): cint;
implementation
- function sock_init: cint;
+ function sock_init: cint; inline;
begin
- sock_init := watt_sock_init(sizeof(tcp_Socket), sizeof(udp_Socket))
+ sock_init := watt_sock_init(sizeof(tcp_Socket), sizeof(udp_Socket), sizeof(cuint)) (* !!! DJGPP *)
end;
function fpFD_SET (fdno: cint; var nset: TFDSet): cint;
index fedd18bed2f73dfdd54b1655db1ad8bc9620d796..4ea4320db52376e87b653f284d8d7975647c9ea3 100644 (file)
uses
{$IFDEF GO32V2}
- {$IFNDEF USE_ENETWRAP}
- Watt32,
- {$ENDIF}
go32,
{$ENDIF}
+ {$IFDEF USE_WATT32}
+ Watt32,
+ {$ENDIF}
e_Log, g_options, SysUtils, Math, Classes, ctypes;
const
procedure AllegroTimerCallback; cdecl;
begin
inc(ticks);
- {$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ {$IFDEF USE_WATT32}
userTimerTick(1);
{$ENDIF}
end;
if useVsync then
vsync;
- {$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ {$IFDEF USE_WATT32}
tcp_tick(nil);
{$ENDIF}
end;
Exit
end;
- {$IF DEFINED(GO32V2) AND NOT DEFINED(USE_ENETWRAP)}
+ {$IFDEF USE_WATT32}
tcp_tick(nil);
{$ENDIF}
end;